Creates and returns a new XML document

 @param [XML::Document,String] obj Object to create the document with
 @return [XML::Document]
185470
def xml_document(obj)
      case obj
      when XML::Document
        XML::Document.document(obj)
      else
        XML::Document.new('1.0')
      end
    end
79269
def newDoc(version):
    
    ret = libxml2mod.xmlNewDoc(version)
    if ret is None:raise treeError('xmlNewDoc() failed')
    return xmlDoc(_obj=ret)
738408
def create_from_xml(xml, pares)
      raise PaResMissing.new "(2500) PaRes argument can not be omitted." if pares.nil?
      @request_xml = REXML::Document.new xml
      REXML::XPath.first(@request_xml, "//ThreeDSecure").add_element("PaRes").text=pares
    end
1014979
def rest_xml
      doc = REXML::Document.new JSS::APIConnection::XML_HEADER
      group = doc.add_element self.class::RSRC_OBJECT_KEY.to_s
      group.add_element('name').text = @name
      group.add_element('is_smart').text = @is_smart
      if @is_smart
        group << @criteria.rest_xml if @criteria
      else
        group << self.class::MEMBER_CLASS.xml_list(@members, :id)
      end

      add_site_to_xml(doc)

      doc.to_s
    end
593877
@Override
    public <A> A fromXML(Document document, Class<A> clazz) {
        return fromXML(stringify(document), clazz);
    }
864168
def rest_xml
      doc = REXML::Document.new APIConnection::XML_HEADER
      periph = doc.add_element RSRC_OBJECT_KEY.to_s

      general = periph.add_element('general')
      general.add_element('type').text = @type
      general.add_element('site').add_element('name').text = @site
      general.add_element('bar_code_1').text = @bar_code_1
      general.add_element('bar_code_2').text = @bar_code_2
      general.add_element('computer_id').text = @computer_id

      fields = general.add_element('fields')
      @fields.each do |n,v|
        fld =  fields.add_element('field')
        fld.add_element('name').text = n
        fld.add_element('value').text = v
      end

      if has_location?
        periph << location_xml
      end
      if has_purchasing?
        periph << purchasing_xml
      end
      add_site_to_xml doc

      return doc.to_s
    end
1016370
function XmlDocument(xml) {
  xml && (xml = xml.toString().trim());

  if (!xml)
    throw new Error("No XML to parse!");

  // Expose the parser to the other delegates while the parser is running
  this.parser = sax.parser(true); // strict
  addParserEvents(this.parser);

  // We'll use the file-scoped "delegates" var to remember what elements we're currently
  // parsing; they will push and pop off the stack as we get deeper into the XML hierarchy.
  // It's safe to use a global because JS is single-threaded.
  delegates = [this];
  
  this.parser.write(xml);

  // Remove the parser as it is no longer needed and should not be exposed to clients
  delete this.parser;
}
105287
def new(*args, &block)
      procedure = find_procedure(:new)
      # in case of collections pass array of elements as one argument for constructor
      if collection? && !(args.size == 1 && args[0].is_a?(Array))
        args = [args]
      end
      result = procedure.exec_with_options(args, { skip_self: true }, &block)
      # TODO: collection constructor should return Array of ObhjectInstance objects
      if collection?
        result
      else
        # TODO: what to do if block is passed to constructor?
        ObjectInstance.create(self, result)
      end
    end
155680
def addObjectFromXML(xmlObject, XMLToObjectFunc,
                     topLevelName, idKey, updateList):
    

    # Get the current object to update
    contentElement = getNodeByName(xmlObject, "content")
    objectNode = getNodeByName(contentElement, topLevelName)
    dupObjects = None
    newObject = XMLToObjectFunc(objectNode)
    try:
        kwargs = {idKey: getattr(newObject, idKey)}
        dupObjects = type(newObject).objects.filter(**kwargs)
    except type(newObject).DoesNotExist:
        pass
    if dupObjects and dupObjects.count() > 1:
        raise Exception(
            "Duplicate object with identifier %s" % getattr(newObject, idKey)
        )
    newObject.save()
    return newObject
1269927
def to_xml_updates(value)
      return if options[:readonly]
      doc = Nokogiri::XML::Document.new
      if value.is_a?(Array)
        value.each do |sub_value|
          sub_field.to_xml_updates(sub_value) do |field_uri_xml, element_xml|
            element_wrapper = doc.create_element(sub_field.tag_name)
            element_wrapper << element_xml
            yield [
              field_uri_xml,
              element_wrapper
            ]
          end
        end
      elsif value.is_a?(Exchanger::Element)
        value.tag_name = tag_name
        if value.class.elements.keys.include?(:text)
          field = value.class.elements[:text]
          yield [
            field.to_xml_field_uri(value),
            field.to_xml(value)
          ]
        else
          # PhysicalAddress ?
          value.class.elements.each do |name, field|
            yield [
              field.to_xml_field_uri(value),
              field.to_xml(value, :only => [name])
            ]
          end
        end
      else # String, Integer, Boolean, ...
        yield [
          self.to_xml_field_uri(value),
          self.to_xml(value)
        ]
      end
    end
703811
def import_xml(node)
      ret = nil

      case node.name
      when 'dict'
        hsh = Hash.new
        key = nil

        if node.children? then
          node.children.each do |n|
            next if n.text? # avoid a bug of libxml
            next if n.comment?

            if n.name == "key" then
              key = get_value(n)
            else
              raise CFFormatError.new("Format error!") if key.nil?
              hsh[key] = import_xml(n)
              key = nil
            end
          end
        end

        if hsh['CF$UID'] and hsh.keys.length == 1
          ret = CFUid.new(hsh['CF$UID'].value)
        else
          ret = CFDictionary.new(hsh)
        end

      when 'array'
        ary = Array.new

        if node.children? then
          node.children.each do |n|
            next if n.text? # avoid a bug of libxml
            next if n.comment?
            ary.push import_xml(n)
          end
        end

        ret = CFArray.new(ary)

      when 'true'
        ret = CFBoolean.new(true)
      when 'false'
        ret = CFBoolean.new(false)
      when 'real'
        ret = CFReal.new(get_value(node).to_f)
      when 'integer'
        ret = CFInteger.new(get_value(node).to_i)
      when 'string'
        ret = CFString.new(get_value(node))
      when 'data'
        ret = CFData.new(get_value(node))
      when 'date'
        ret = CFDate.new(CFDate.parse_date(get_value(node)))
      end

      return ret
    end
540293
def to_xml(data)
      ox = XML::Node.new(ox_tag)
      wrappers = {}
      
      ox_elems.each do |elem|
        if elem.in
          wrappers[elem.in] ||= XML::Node.new elem.in
          elem.to_xml(data).each {|e| wrappers[elem.in] << e}
        else
          elem.to_xml(data).each {|e| ox << e}
        end
      end
      
      wrappers.each {|k,v| ox << v}
      
      ox_attrs.each do |a| 
        val = data.send(a.accessor).to_s
        ox[a.tag]= val if val.present?
      end
      
      ox
    end
240210
def newNode(name):
    
    ret = libxml2mod.xmlNewNode(name)
    if ret is None:raise treeError('xmlNewNode() failed')
    return xmlNode(_obj=ret)
500285
def newDocRawNode(self, ns, name, content):
        
        if ns is None: ns__o = None
        else: ns__o = ns._o
        ret = libxml2mod.xmlNewDocRawNode(self._o, ns__o, name, content)
        if ret is None:raise treeError('xmlNewDocRawNode() failed')
        __tmp = xmlNode(_obj=ret)
        return __tmp
680595
function(node) {
        var data;
        if(this.xmldom) {
            data = node.xml;
        } else {
            var serializer = new XMLSerializer();
            if (node.nodeType == 1) {
                // Add nodes to a document before serializing. Everything else
                // is serialized as is. This may need more work. See #1218 .
                var doc = document.implementation.createDocument("", "", null);
                if (doc.importNode) {
                    node = doc.importNode(node, true);
                }
                doc.appendChild(node);
                data = serializer.serializeToString(doc);
            } else {
                data = serializer.serializeToString(node);
            }
        }
        return data;
    }
1351703
def new
      @faq = Cmtool::Faq.new

      respond_to do |format|
        format.html # new.html.erb
        format.xml  { render :xml => @faq }
      end
    end
767644
@Override
    public Document createDocument(Document parentDocument) {
        Ruby runtime = JRubyRuntimeContext.get(parentDocument);
        RubyHash options = RubyHash.newHash(runtime);
        options.put(
                runtime.newSymbol("parent"),
                ((DocumentImpl) parentDocument).getRubyObject());

        return (Document) NodeConverter.createASTNode(runtime, NodeConverter.NodeType.DOCUMENT_CLASS, runtime.getNil(), options);
    }