Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2779

GPath evaluation problem for html with namespace

    XMLWordPrintableJSON

Details

    Description

      I am trying to parse HTML with XmlParser (see example below).

      I expect both expressions
      html.body
      and
      html.":body"
      will return the same value, since namespace prefix is empty.

      But the first one does not work (it rerurns empty list).

      Sorce code:

      import groovy.xml.*
      def text = """
      <html xmlns="http://www.w3.org/1999/xhtml">
          <body>
              text
          </body>
      </html>
      """
      def html = new XmlParser().parseText(text)
      println html.body  
      println html.":body"
      

      Result:
      []
      [

      {http://www.w3.org/1999/xhtml}

      body[attributes={}; value=[text]]]

      Attachments

        Activity

          People

            paulk Paul King
            enterit Sergey Bondarenko
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: