Parses a document and yields the contained SVG nodeset to the given block
 if it exists.

 Returns a Nokogiri::XML::Document.
483420
def with_svg(doc)
      doc = Nokogiri::XML::Document.parse(
        doc.to_html(encoding: "UTF-8"), nil, "UTF-8"
      )
      svg = doc.at_css "svg"
      yield svg if svg && block_given?
      doc
    end
831088
def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'w'
          @width = value.value.to_f
        when 'h'
          @height = value.value.to_f
        when 'stroke'
          @stroke = value.value.to_f
        end
      end
      node.xpath('*').each do |node_child|
        @elements << DocxShapeLineElement.new(parent: self).parse(node_child)
      end
      self
    end
1113298
def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'gridSpan'
          @grid_span = value.value.to_i
        when 'hMerge'
          @horizontal_merge = value.value.to_i
        when 'vMerge'
          @vertical_merge = value.value.to_i
        end
      end

      node.xpath('*').each do |node_child|
        case node_child.name
        when 'txBody'
          @text_body = TextBody.new(parent: self).parse(node_child)
        when 'tcPr'
          @properties = CellProperties.new(parent: self).parse(node_child)
        when 'p'
          @elements << DocumentStructure.default_table_paragraph_style.dup.parse(node_child,
                                                                                 0,
                                                                                 DocumentStructure.default_table_run_style,
                                                                                 parent: self)
        when 'sdt'
          @elements << StructuredDocumentTag.new(parent: self).parse(node_child)
        when 'tbl'
          @elements << Table.new(parent: self).parse(node_child)
        end
      end
      self
    end
1086154
def create_node(doc, node_name, content=nil) #:doc:
      node = Nokogiri::XML::Node.new(node_name, doc)
      node.content = content if content
      node
    end
914855
def parseXRDS(text):
    
    try:
        element = ElementTree.XML(text)
    except XMLError, why:
        exc = XRDSError('Error parsing document as XML')
        exc.reason = why
        raise exc
    else:
        tree = ElementTree.ElementTree(element)
        if not isXRDS(tree):
            raise XRDSError('Not an XRDS document')

        return tree
1219556
def parse(data)
      if !data.respond_to?(:read)
        data = StringIO.new(data || "")
      end

      if data.eof?
        {}
      else
        silence_warnings { require "rexml/document" } unless defined?(REXML::Document)
        doc = REXML::Document.new(data)

        if doc.root
          merge_element!({}, doc.root, XmlMini.depth)
        else
          raise REXML::ParseException,
            "The document #{doc.to_s.inspect} does not have a valid root"
        end
      end
    end
1314715
def _docstring_parse(self, blocks):
        """"""
        result = {}
        for block, docline, doclength, key in blocks:
            doctext = "<doc>{}</doc>".format(" ".join(block))
            try:
                docs = ET.XML(doctext)
                docstart = self.parser.charindex(docline, 0, self.context)
                if not key in result:
                    result[key] = [list(docs), docstart, docstart + doclength]
                else:
                    #If there are docblocks separated by whitespace in the
                    #same element we can't easily keep track of the start and
                    #end character indices anymore.
                    result[key][0].extend(list(docs))
            except ET.ParseError:
                msg.warn(doctext)

        return result
1092336
def parse(self, *nodes):
        
        for n in nodes:
            if not n.contents:
                continue
            row = self._parse(n)
            if not row.is_null:
                yield row
918846
def parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'blipFill'
          @path_to_image = DocxBlip.new(parent: self).parse(node_child)
        when 'spPr'
          @properties = DocxShapeProperties.new(parent: self).parse(node_child)
        when 'nvPicPr'
          @non_visual_properties = NonVisualShapeProperties.new(parent: self).parse(node_child)
        end
      end
      self
    end
862568
def parse(node)
      node.xpath('*').each do |node_child|
        begin
          node_child.xpath('w:drawing')
        rescue Nokogiri::XML::XPath::SyntaxError # This mean it is Chart
          case node_child.name
          when 'Choice'
            @office2010_content = ChartStyle.new(parent: self).parse(node_child)
          when 'Fallback'
            @office2007_content = ChartStyle.new(parent: self).parse(node_child)
          end
          next
        end
        case node_child.name
        when 'Choice'
          @office2010_content = DocxDrawing.new(parent: self).parse(node_child.xpath('w:drawing').first) unless node_child.xpath('w:drawing').first.nil?
          @choice = Choice.new(parent: self).parse(node_child)
        when 'Fallback'
          @office2007_content = OldDocxPicture.new(parent: self).parse(node_child.xpath('w:pict').first) unless node_child.xpath('w:pict').first.nil?
        end
      end
      self
    end
1111155
def _parse_docblocks(self, string, container):
        
        #The easiest way to do this is to look at one line at a time and see if it is a docstring
        #When we find a group of docstrings that suddenly ends, the next item is the code element
        #that they were decorating (which may or may not be pertinent).
        from fortpy.utility import XML
        current = []
        docblocks = {}
        docstart = 0

        for line in string.split("\n"):
            match = self.RE_DOCS.match(line)
            if match is not None:
                current.append(match.group("docstring"))
                if len(current) == 1:
                    #This was the first docstring of a new documentation block.
                    docend = docstart + len(line) + 1  # +1 for \n removed by split()
                else:
                    #We already have some docstrings in the block, update start/end
                    docend += len(line) + 1
            else:
                #See if we were previously working on a docstring block or not.
                if len(current) > 0:
                    #Save all the current docstrings in the blocks dictionary
                    #under the name of the code element in this line.
                    key = self._parse_docline(line, container)
                    #If the docblock has multiple XML tags at the same depth, the XML
                    #parser will scream. Wrap everything in a doc tag.
                    doctext = "<doc>{}</doc>".format(" ".join(current))
                    try:
                        #Let the docstart and docend *always* be absolute character references.
                        tabsstart, tabsend = container.module.absolute_charindex(string, docstart, docend-len(line))
                        emsg="module '{0}' docstring starting @ {1[0]}:{1[1]}"
                        emsg=emsg.format(container.module.name, container.module.linenum(tabsstart))
                        docs = XML(doctext, emsg)
                        if not key in docblocks:
                            absstart, absend = tabsstart, tabsend
                            docblocks[key] = [list(docs), absstart, absend]
                        else:
                            docblocks[key][0].extend(list(docs))
                    except ET.ParseError as err:
                        msg.err(err.msg)

                    #Reset the list of current docstrings
                    current = []
                    docstart = docend + len(line) + 1
                else:
                    #We need to keep track of the line lengths for docstart/end.
                    docstart += len(line) + 1

        return docblocks
574201
def parse(node)
      @properties = OldDocxShapeProperties.new(parent: self).parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'textbox'
          @text_box = TextBox.parse_list(node_child, parent: self)
        when 'imagedata'
          @file_reference = FileReference.new(parent: self).parse(node_child)
        when 'fill'
          @fill = OldDocxShapeFill.new(parent: self).parse(node_child)
        end
      end
      self
    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
247782
def parse_xml(self, node):
        
        self._set_properties(node)
        self.extend(TiledObject(self.parent, child)
                    for child in node.findall('object'))

        return self
816117
def parse(node)
      text_box_content_node = node.xpath('w:txbxContent').first
      text_box_content_node.xpath('*').each_with_index do |node_child, index|
        case node_child.name
        when 'p'
          @elements << DocxParagraph.new(parent: self).parse(node_child, index)
        when 'tbl'
          @elements << Table.new(parent: self).parse(node_child, index)
        when 'bodyPr'
          @properties = OOXMLShapeBodyProperties.new(parent: self).parse(node_child)
        end
      end
      self
    end
886204
def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'w'
          @width = OoxmlSize.new(value.value.to_f, :emu)
        when 'cap'
          @cap = value_to_symbol(value)
        end
      end

      node.xpath('*').each do |node_child|
        case node_child.name
        when 'solidFill'
          @color_scheme = DocxColorScheme.new(parent: self).parse(node_child)
        when 'noFill'
          @width = OoxmlSize.new(0)
        when 'headEnd'
          @head_end = LineEnd.new(parent: self).parse(node_child)
        when 'tailEnd'
          @tail_end = LineEnd.new(parent: self).parse(node_child)
        when 'prstDash'
          @dash = ValuedChild.new(:symbol, parent: self).parse(node_child)
        end
      end
      self
    end
783371
function parse (node, self) {
  let block = false

  if (node.nodeType === 3) {
    let delimiters = self.templateDelimiters

    if (delimiters) {
      let tokens = parseTemplate(node.data, delimiters)

      if (tokens.length) {
        if (!(tokens.length === 1 && tokens[0].type === 0)) {
          tokens.forEach((token, i) => {
            let text = document.createTextNode(token.value)
            node.parentNode.insertBefore(text, node)

            if (token.type === 1) {
              self.buildBinding(TextBinding, text, null, token.value)
            }
          })

          node.parentNode.removeChild(node)
        }
      }
    }
  } else if (node.nodeType === 1) {
    block = self.traverse(node)
  }

  if (!block) {
    Array.prototype.slice.call(node.childNodes).forEach(function (node) { parse(node, self) })
  }
}