views:

233

answers:

2

Hey guys! This is driving me NUTS! Here's 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. Any help would be appreciated... Sam

+2  A: 

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.

Alex Reynolds
dude, I think you're right on. Apparently touch xml has some problemsthat are know with xPath. I'm gonna try to fix them! Who knows, maybe someone will benefit?
Sam
That's a nice thing about open source. Good luck!
Alex Reynolds
+1  A: 

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