3

Here is my XML document:

<?xml version="1.0" encoding="UTF-8"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
   <rootfiles>
        <rootfile full-path="content.opf" media-type="application/oebps-package+xml"/>
    </rootfiles>
</container>

All I want to do is get the root file element. I'm using TouchXML on the iPhone and here is my xPath query:

/container/rootfiles/rootfile

It doesn't work! I've tried everything.

peterh
  • 11,875
  • 18
  • 85
  • 108
Sam Stewart
  • 1,470
  • 3
  • 14
  • 14

2 Answers2

2

That xmlns bit within the container node is a namespace prefix that you may have your query register.

I don't know TouchXML well enough to say what the solution is, but the relevant libxml2 call is xmlXPathRegisterNs() if you go into the innards of TouchXML.

This SO answer might also help point you to the right TouchXML method to use to register this namespace.

Community
  • 1
  • 1
Alex Reynolds
  • 95,983
  • 54
  • 240
  • 345
1

I am not a specialist in TouchXML, but this may help you.

There is also a somewhat ugly pure XPath solution.

Use:

/*[name()='container']/*[name()='rootfiles']/*[name()='rootfile']
Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431