Extract a page's worth of records from a Primo XML search result.
 @param xml [String] an XML document returned from a Primo search
 @return [Array] an array of @record_class instances
503655
def enumerate_records(xml)
      doc = Nokogiri::XML(xml)
      doc.root.add_namespace_definition('nmbib', PRIMO_NS)
      doc.xpath('//sear:DOC').lazy.map do |record|
        identifier = record.xpath('./nmbib:PrimoNMBib/nmbib:record/' \
                                  'nmbib:control/nmbib:recordid')
                     .first.text

        record = record.dup
        record.add_namespace_definition('sear', SEAR_NS)

        @record_class.build(mint_id(identifier), record.to_xml)
      end
    end
661042
def parse(string)
      LibXML::XML.default_keep_blanks = false

      if string.blank?
        {}
      else
        LibXML::XML::Parser.string(string.strip).parse.to_hash
      end
    end
414552
def parse(self, xml_str):
        # type: (str) -> List[EndpointDescription]
        
        # Parse the document
        root = ElementTree.fromstring(xml_str)
        if root.tag != TAG_ENDPOINT_DESCRIPTIONS:
            raise ValueError("Not an EDEF XML: {0}".format(root.tag))

        # Parse content
        return [
            self._parse_description(node)
            for node in root.findall(TAG_ENDPOINT_DESCRIPTION)
        ]
72785
def build(xml, start_index = 0)
    super do |xml|
      [:url, :name, :email, :position, :organization, :additional, :phone, :address].each do |key|
        if @vcard.has_key?(key)
          xml.tag!(key, @vcard[key])
        end
      end
    end
  end
90740
def get_records(self, sequence_id, gt=None, gte=None, lt=None, lte=None, limit=None,
                    query_ascending=True, results_ascending=True):
        
1374042
def parse(xml)
      @hash     = Hash.from_xml(xml)
      @server   = Server.new(@hash["monit"]["server"])
      @platform = Platform.new(@hash["monit"]["platform"])

      options = {
        :host     => @host,
        :port     => @port,
        :ssl      => @ssl,
        :auth     => @auth,
        :username => @username,
        :password => @password
      }

      if @hash["monit"]["service"].is_a? Array
        @services = @hash["monit"]["service"].map do |service|
          Service.new(service, options)
        end
      else
        @services = [Service.new(@hash["monit"]["service"], options)]
      end
      true
    rescue
      false
    end
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
715012
function(xml) {
    var contexp, fn, formatted, indent, l, lastType, len, lines, ln, pad, reg, transitions, wsexp;
    reg = /(>)(<)(\/*)/g;
    wsexp = /[ ]*(.*)[ ]+\n/g;
    contexp = /(<.+>)(.+\n)/g;
    xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
    pad = 0;
    formatted = '';
    lines = xml.split('\n');
    indent = 0;
    lastType = 'other';
    transitions = {
      'single->single': 0,
      'single->closing': -1,
      'single->opening': 0,
      'single->other': 0,
      'closing->single': 0,
      'closing->closing': -1,
      'closing->opening': 0,
      'closing->other': 0,
      'opening->single': 1,
      'opening->closing': 0,
      'opening->opening': 1,
      'opening->other': 1,
      'other->single': 0,
      'other->closing': -1,
      'other->opening': 0,
      'other->other': 0
    };
    fn = function(ln) {
      var fromTo, j, key, padding, type, types, value;
      types = {
        single: Boolean(ln.match(/<.+\/>/)),
        closing: Boolean(ln.match(/<\/.+>/)),
        opening: Boolean(ln.match(/<[^!?].*>/))
      };
      type = ((function() {
        var results;
        results = [];
        for (key in types) {
          value = types[key];
          if (value) {
            results.push(key);
          }
        }
        return results;
      })())[0];
      type = type === void 0 ? 'other' : type;
      fromTo = lastType + '->' + type;
      lastType = type;
      padding = '';
      indent += transitions[fromTo];
      padding = ((function() {
        var m, ref1, results;
        results = [];
        for (j = m = 0, ref1 = indent; 0 <= ref1 ? m < ref1 : m > ref1; j = 0 <= ref1 ? ++m : --m) {
          results.push('  ');
        }
        return results;
      })()).join('');
      if (fromTo === 'opening->closing') {
        formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
      } else {
        formatted += padding + ln + '\n';
      }
    };
    for (l = 0, len = lines.length; l < len; l++) {
      ln = lines[l];
      fn(ln);
    }
    return formatted;
  }
353754
def parseResponseXML( xml )
      if xml
         xml.gsub!( "\r", "" ) if @ignoreCR and @ignoreCR == true
         xml.gsub!( "\n", "" ) if @ignoreLF and @ignoreLF == true
         xml.gsub!( "\t", "" ) if @ignoreTAB and @ignoreTAB == true
         xml.gsub!( "<BR/>", "&lt;BR/&gt;" ) if @escapeBR
         @qdbapi = @responseXMLdoc = REXML::Document.new( xml )
      end
   end
770796
def find_entities(results)
      document = ::Nokogiri::XML(results.body)
      document.remove_namespaces!
      document.xpath('//entry')
    end
1007535
def build_xml(node, doc = nil, xml_node = nil)
      doc, xml_node = xml_document(doc, xml_node)

      if node.respond_to?(:each)
        node.each do |child|
          if position_node?(child)
            xml_position_node(doc, xml_node, child)
          else
            if ast_node_has_children?(child)
              # The AST structure is different for hashes so we have to treat
              # them separately.
              if ast_hash_node?(child)
                xml_hash_node(doc, xml_node, child)
              else
                xml_array_node(doc, xml_node, child)
              end
            else
              xml_node["value"] = child.to_s unless child.nil?
            end
          end
        end
      end
      xml_node
    end
636808
def to_xml
      return nil if title.nil? || body.nil?

      xml = ""
      xml << "<d:entry id=\"#{self.id}\" d:title=\"#{self.title}\">\n"
      @index.each do |i|
        xml << "\t<d:index d:value=\"#{i}\" d:title=\"#{title}\" "
        xml << "d:yomi=\"#{yomi}\"" if !self.yomi.nil?
        xml << "/>\n"
      end
      xml << "\t<div>\n"
      xml << "\t\t#{@body}\n"
      xml << "\t</div>\n"
      xml << "</d:entry>\n"

      return xml
    end
719788
def extract_paging(response)
      paging            = response.to_h['paging']
      next_page_url     = paging && paging['next']      # gives nil when any one of the keys doens't exist
      previous_page_url = paging && paging['previous']  # can be replaced with Hash#dig for ruby >= 2.3.0
      @paging_next      = extract_endpoint_from(next_page_url)
      @paging_previous  = extract_endpoint_from(previous_page_url)
    end
883119
@XmlElementWrapper(name = "pages")
  @XmlElement(name = "page", type = Page.class)
  public List<Page> getPages() {
    return pages;
  }
941301
def parse
      return nil unless File.file?(@file)

      doc = parse_xml(@file)
      doc.xpath('w:comments/*').each do |node_child|
        case node_child.name
        when 'comment'
          @comments_array << Comment.new(parent: self).parse(node_child)
        end
      end
      self
    end
502959
private function process($xml): array
    {
        $parent = (string) $xml->{'name'};
        $defaultTtl = (int) $xml->{'default-ttl'};
        $resourceRecords = [];

        foreach ($xml->{'resource-records'}->{'resource-record'} as $rr) {
            $name = (string) $rr->{'name'} ?? $parent;
            $class = isset($rr->{'class'}) ? ClassEnum::getClassFromName($rr->{'class'}) : $this->defaultClass;
            $ttl = isset($rr->{'ttl'}) ? (int) $rr->{'ttl'} : $defaultTtl;

            $resourceRecords[] = (new ResourceRecord())
                ->setName($this->handleName($name, $parent))
                ->setClass($class)
                ->setType($type = RecordTypeEnum::getTypeFromName($rr->{'type'}))
                ->setTtl($ttl)
                ->setRdata($this->extractRdata($this->simpleXmlToArray($rr->{'rdata'}), $type, $parent));
        }

        return $resourceRecords;
    }
907501
def _get_existing_records(cr, fp, module_name):
    """"""
    def yield_element(node, path=None):
        if node.tag not in ['openerp', 'odoo', 'data']:
            if node.tag == 'record':
                xmlid = node.attrib['id']
                if '.' not in xmlid:
                    module = module_name
                else:
                    module, xmlid = xmlid.split('.', 1)
                cr.execute(
                    'select id from ir_model_data where module=%s and name=%s',
                    (module, xmlid)
                )
                if not cr.rowcount:
                    return
            result = StringIO(etree.tostring(path, encoding='unicode'))
            result.name = None
            yield result
        else:
            for child in node:
                for value in yield_element(
                        child,
                        etree.SubElement(path, node.tag, node.attrib)
                        if path else etree.Element(node.tag, node.attrib)
                ):
                    yield value
    return yield_element(etree.parse(fp).getroot())