groovy
  1. groovy
  2. GROOVY-2779

GPath evaluation problem for html with namespace

    Details

    • Number of attachments :
      0

      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]]]

        Activity

        Hide
        Paul King added a comment -

        add code tags

        Show
        Paul King added a comment - add code tags
        Hide
        Paul King added a comment -

        Fixed in trunk - still to add test and merge to 1.6 and 1.5 releases.

        Show
        Paul King added a comment - Fixed in trunk - still to add test and merge to 1.6 and 1.5 releases.
        Hide
        Sergey Bondarenko added a comment -

        Paul, thank you!
        Now it works properly.

        Show
        Sergey Bondarenko added a comment - Paul, thank you! Now it works properly.
        Hide
        Paul King added a comment -

        Test added and merged onto 1.5 and 1.6 branches.

        Show
        Paul King added a comment - Test added and merged onto 1.5 and 1.6 branches.

          People

          • Assignee:
            Paul King
            Reporter:
            Sergey Bondarenko
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: