LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos
GarryG

XML parsing get node text content and single node when containing < or >

Status: Declined

Please update the XML parsing pallette (specifically the load VI and Node.XML invoke node) to be able to get the actual text contents of a node when it contains ">" or "<".  Currently, if the node text contains ">", the Result XML of the node is displayed, with "&gt;" substituted for ">".  If the node text contains <, the XML document won't even load and throws an error.

 

To see this behavior, use the LabVIEW example: Query XML Document for a Single Node.vi

 

Modify any text tag contents to contain either of these characters.

 

 

CLA, CTA
Not my tempo... AGAIN!
17 Comments
Darin.K
Trusted Enthusiast

What LV version are you working with?  That XML is fine in LV12.  Great news.

 

Entities will have to wait, as will fixing the export strings pseudo-XML.

 

I'd call this Already Implemented.  I did not see it in the release notes, but a lot of times when the external libraries they use are updated those changes aren't always reflected.

GarryG
Member

Hmm....

2011 sp1.  I work at a company with a large number of LV licenses.  We're slow to update because of the risk and number of man hours associated with it.  I'll get a copy of 2012 sp1 and try it.  Thanks for the update!

CLA, CTA
Not my tempo... AGAIN!
Darin.K
Trusted Enthusiast

Works for me in LV9, closing in on Pilot Error here.  I was too quick to blame NI here because of the pain I suffered with parsing the exported strings format...

 

I can take that snippet of XML, use Load to get the XML document, Find First Node with //Value as the XPath string, find the node's First child, and then get its value.  The CDATA section is removed and I get the content < > and whatnot.

 

 

 

 

GarryG
Member

When you say "get its value" what VI are you using to do so?  I get an empty string out of the Get Node Text Content.vi after trying several attempts to recreate what you stated above.  Can you attach an example?

CLA, CTA
Not my tempo... AGAIN!
Darin.K
Trusted Enthusiast

CDataXML.png

GarryG
Member

Ok... I'm learning!  Much appreciated!


So I find this interesting for a couple reasons:

 

1.  I didn't think in the context that //Value had a child (but I guess the text is considered a child in and of itself?). 

2.  The VI Get Node Text Content doesn't recognize this as text.... it outputs an empty string.  Digging down in this VI, it's using the Node.Type property to identify text nodes.  It sees this node as type = Element_Node (it only gets the text of a Text_Node).  Interestingly, there is a CDATASection_Node, and it does not identify it as such.

 

Thank you so much for the solution though!  I suppose I'll stick with the property nodes and avoid the out of the box VI's.

CLA, CTA
Not my tempo... AGAIN!
Darin.K
Trusted Enthusiast

You have learned a valuable lesson here.  The library code which lies beneath the Property and Invoke Nodes is an external library which has been developed by a team focussed on XML parsing.  It has been extensively unit tested and used in real world applications. 

 

VIs like Get Node Text Content are written by NI developers.  They are quite good, but do not have the sharp focus of the library developers.  The unit tests are much less extensive, and many such VIs are only used by a small subset of users.  Bugs are fixed as reported, but the burden is really on the users.  If you are in the 95% then it works great for all of your needs.  If you are in the other 5% then it is a pain.

 

I live in the 5% it seems, if not the 1%.

 

If it has a Block Diagram I suggest you look before you leap.