I use an xpath expression, trying to select node-set in an XML document with different namespaces I am here.
XML looks like this:
& Lt; OrderNo & gt; 20090811 & lt; / OrderNo & gt; & Lt; Status & gt; 0 & lt; / Status & gt; & Lt; / Header & gt; & Lt; Lines & gt; ...
I just want to select "message" -node, in which "orderstatus" is a child and therefore I want to use the following xpath expression: / message [count ( 'Orderstats') & gt; 0] but it will not work when I get an error message: "Namespace Manager or XsltContext is required. This query contains a prefix, variable, or user defined function".
So I think I want to use an expression that looks like this: / * [local-name (=) 'message'] [count ('orderstats') & Gt; 0] But this does not seem to work. Any ideas?
BR,
Andreas
/ message [count ('orderstats') [0]
but it will not work since I get an error message : "Namespace Manager or XsltContext is required.
This is a frequently asked question.
An unused name in an XP is not always considered as "a name space".
However, to select the element you want, actually in "http://www.noventus.se/epix1/genericheader.xsd"
namespace Are there.
You have two possible ways to write your XPath expression :
- The hosting language to associate the prefixes with all the different namespaces Use the features of which have names from expressions. You have not indicated what hosting is a minor in this concrete case, so I can not help you with this. A C # example can be found
"xxx"
to the namespace "http://www.noventus.se/epix1/genericheader.xsd"
and the alias "Yyy"
at the place name of "http://www.noventus.se/epix1/orderstatus.xsd"
, then your expression can be written as: / xxx: message [yyy: orderstatus]
: 2: if you come If you do not want to use any prefix at all, XPath expression can still be prepared, though it will not be even readable:
/ * [local-name () = 'message
Finally, note :
[local-name () = 'order-status']
To check that an element is
x
a childy
, it is necessary to test for a positivecount (y)
is not. Use :x [y]
-
Expath state is 1-based This means that the
nodextexpress [0]
never selects the node you want:nodeet encryption [1]
Comments
Post a Comment