Jump to content

XML, XPath and namespaces


NeilA

Recommended Posts

I have gotten used to the awkwardness of XML in LabVIEW but have just come up against a massive problem of using XPath and trying to parse namespaced xml. Basically where XPath used to do the trick it now doesnt because parts of my xml are in a different namespaces. I cant figure out how to get acces to the namespace manager or anything (which is what you need to do according to google). I need to talk to my colleague who has just added the namespaces and made my day very hard, but, I may just remove them for my simple implementation if there is no way round it in LabVIEW.

I have attached an example XML where I used to be able to loadXML String and then SelectSingleNode with an XPath of /soap:Envelope/soap:Header/UUID/UUID to get the guid.

Any ideas on what to use? I have had a look round in the constructors but cant work out how to do this, is it me or does this just seem like even more hard work, blooming XML :headbang:

Many Thanks in advance..

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Header>

<UUID xmlns="http://RMS/">

<UUID>guid</UUID>

</UUID>

</soap:Header>

<soap:Body>

<ControlResume xmlns="http://RMS/">

<ParameterList>

<Parameter>

<Type>string</Type>

<Name>string</Name>

<Value>

<string>string</string>

<string>string</string>

</Value>

<Units>string</Units>

</Parameter>

<Parameter>

<Type>string</Type>

<Name>string</Name>

<Value>

<string>string</string>

<string>string</string>

</Value>

<Units>string</Units>

</Parameter>

</ParameterList>

</ControlResume>

</soap:Body>

</soap:Envelope>

Link to comment

QUOTE (MJE @ Apr 6 2009, 07:24 PM)

Sorry to be an idiot but could you please explain further? I have tried using different namespaces and xpath combinations but cant get any further, are you suggesting that I still use SelectSingleNode method of the xpath class but with a different xpath!?!

Thanks

Link to comment

QUOTE (Matthew Zaleski @ Apr 6 2009, 09:23 PM)

Welcome to the world of XML. :(

Yeah Thanks,

I have been happily using XPath without any issues but the addition of namespaces has seemed to just add headaches. I dont have control of the namespaces this XML is the soap message sent to me from another system.

I have been playing around with the LabVIEW XML parser property and invoke nodes as they contain a function to ignore the namespaces but the LabVIEW implementation is based around DOM and I find it really cumbersome after XPath plus I dont really want to re-write everything.

Is there any way I can access the namespaces myself (ie namespace manager/nametable (bear in mind I got this info from the net I have only just heard about them and I dont know if I am asking the correct thing lol!))to recover the XPath solutions I have already implemented.

Thanks for the help so far.

Neil.

Sorry, Not to worry chatted to my colleague doing my other system. I am pretty certain that I will always be using the RMS namespace etc. So to make it easier I have the incoming message pass through a vi that removes all the namespace stuff and makes it work again in XPath.

Thanks for all your help though.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.