Guest Kashmulik Posted February 23, 2008 Share Posted February 23, 2008 Hi,I use xquery in order to retrieve some data from an xml file. The xml I get has the following structure: <a> <b xmlns:"someNamespace"> <c>val1</c> <d>val2</d> <e> <f>val3</f> <g>val4</g> </e> </b> <b xmlns:"someNamespace"> . . . </b>.. .</a> The problem is, that all of the nodes that I want to retrieve their data have the same namespace ("someNamespace") but I don't want to write it any time I address some node. Unfortunately I can't declare a global namespace because the root node "a" is not in the namespace...Does anyone have a solution to my problem?thnx Link to comment Share on other sites More sharing options...
boen_robot Posted February 24, 2008 Share Posted February 24, 2008 Can't you declare a default namespace for all nodes inside "/*"? I would have thought XQuery would allow you to do something like that. If not, then there must be a way with which in XQuery, you can designate a prefix (say "s" for example) that will have the namespace URI "someNamespace". When you do your query, you'll just have to reference the prefix all the time, like s:b/s:c If you really want to match those elements regardless of their namespace URI, you can use something like *[local-name() = 'b']/*[local-name() = 'c'] but if you ask me, that's even uglyer.BTW, your XML is not well formed. It should be xmlns="someNamespace" Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.