05-31-2018 03:40 PM
Hi all,
I have an XML Schema like so:
<?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Data"> <xs:element name="Sample"> <xs:element name="Parameter"> Chemical_Name </xs:element> </xs:element> </xs:element> </xs:schema>
I'd like to extract the text "Chemical_Name", which I have done successfully with the following code:
The XPath expression I'm using is:
//element[@name='Data']//element[@name='Sample']//element[@name='Parameter']/text()
My question is this:
When I use xs:element instead of element in the XPath expression, it tells me the prefix is invalid, even though it is quite clearly defined in the schema. This is the case when I do not remove the "xs:" from the XML, and when I do.
Also, why is there so much whitespace surrounding the resultant value?
Solved! Go to Solution.
05-31-2018 03:52 PM
An XML Schema is NOT a XML document. It is a style sheet for a XML document.
The schema does not contain any data, only a description of the elements in a XML document and the setting for each element.
06-01-2018 08:22 AM
@ijustlovemath wrote:
Also, why is there so much whitespace surrounding the resultant value?
The Node.Value property will return everything between the opening and closing tags. Since there are newline and space characters they will be present at the output. Use Trim Whitespace.vi to get get rid of the whitespace at the beginning and at the end of the returned value.
Ben64