ruby - Alternative Syntax for an XPath in nokogiri, parsing an ODF -


I have a very simple ODF document that I want to parse with the nokia.

The XML looks like this:

Currently I'm trying to select the categorylevel1 section of the document. The library generates XPath automatically and produces. ".// text: section [@text: name = 'categorylevel1']"
The problem is that the library (nocogly) accepts this path under MRI but Not under JRB (a syntax throws error). Apparently the Java version of the library does not support namespace properties.

Is there any alternative way to refer to the section of the document? For example, using only the text: name attribute? Is there any way to ignore the namespace? The section's text: name attribute value will be unique to the whole document so that mis-referencing will not be a problem.

"Is there any alternative way of referencing section of the document? Using the text: Name attribute? "

You can ignore the element name by using * , in this way you reference the element Only the text can use: Name attribute :

  .//* [@ text: name = 'categorylevel1']  

"Is there any way to ignore the namespace?"

You are named To ignore the information, you can use local-name () for example, ignoring the namespace of the attribute, filter the element with the text: name attribute value To:

  .//* [@ * [local-name () = 'name' and. = 'Categorylevel1']]  

Comments