RaptureXML icon indicating copy to clipboard operation
RaptureXML copied to clipboard

XPath not fetching nodes?

Open matt-curtis opened this issue 11 years ago • 7 comments

Hey,

Nice work! It's proven to be a nice alternative to some of the other xml readers out there.

I'm having an issue with RaptureXML not parsing XPath selectors correctly on my XML. This issue doesn't occur when manually traversing with child and children selectors. My issue is the exact same as the one here: http://stackoverflow.com/questions/14331087/xpath-with-rapturexml-not-matching-nodes

I think the issue might have something to do with namespaces but I'm not sure how to fix that.

Any suggestions?

Thanks!

matt-curtis avatar Mar 16 '13 21:03 matt-curtis

Harumph. The XPath stuff uses what libxml2 provides. I bet it's a syntax issue. You might check the libxml2 docs. I won't get a chance to find a solution for a bit as I'm going through a move and some downtime. Let me know if you find out anything.

(FWIW, I never use the XPath component of RaptureXML. I added it per a feature request.)

ZaBlanc avatar Mar 17 '13 03:03 ZaBlanc

I'm just using iterate for now. BTW, was a 'break' statement ever implemented? How do you pull off your tag/attribute queries? The only time I've gotten an XPath query to work is with "//*"

matt-curtis avatar Mar 17 '13 04:03 matt-curtis

Any updates on this?

matt-curtis avatar Nov 16 '13 18:11 matt-curtis

The root of the issue seems to be with how libxml reacts to xml namespaces. http://stackoverflow.com/questions/3830553/libxml-doesnt-find-any-nodes-for-my-xpath-expression

My XML used custom xml namespaces, and libxml requires those namespaces, annoyingly, to be registered and referenced specifically in the xpath query. Anyway, for now, to get around this I'm just stripping out the xmlns attribute.

I would suggest, essentially, allowing for a function that initializes the RXMLElement ignoring namespaces.

matt-curtis avatar Nov 16 '13 21:11 matt-curtis

Matt, This is a good parser, I link the simplicity of it. But the XPath stuff just doesn't work. It would be nice to mention in the readme that this feature is not yet functional. Could save some precious hours for whoever tries to use it next.

Thanks and sorry for the moan.

matatwillow avatar Nov 19 '13 21:11 matatwillow

Well, here's the thing - technically, it is working as it should. I've only seen it not work with namespaced XML, and that's because of libxml, which it is built on. And even in libxml xpath works, you just have to state your namespace if there's one. So, if anything, there could be convenience functionality added for this or or a line in the readme explicitly stating that, or whatever, but it does work.

matt-curtis avatar Nov 19 '13 21:11 matt-curtis

I see, yeah, so it works for some, I think it certainly warrants a mention in the readme. Namespaced XML is not uncommon.

matatwillow avatar Nov 19 '13 21:11 matatwillow