LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

XML Parsing: NI_XML.lvlib:Get All Matched Nodes.vi <append> XML Parser reported the following: The prefix 'xs' is not declared

Solved!
Go to solution

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:

xml.png

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?

 

0 Kudos
Message 1 of 3
(2,635 Views)
Solution
Accepted by topic author ijustlovemath

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. 

0 Kudos
Message 2 of 3
(2,630 Views)

@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

0 Kudos
Message 3 of 3
(2,577 Views)