I am trying to use xpath1
, on the following SOAP XML file:
I tried a simple one:
% ./xpath1 SR_ADULT_007.ExamCard "//SOAP-ENC:Array[@id='ref-297']"
XPath error : Undefined namespace prefix
Error: unable to evaluate xpath expression "//SOAP-ENC:Array[@id='ref-297']"
Usage: ./xpath1 <xml-file> <xpath-expr> [<known-ns-list>]
where <known-ns-list> is a list of known namespaces
in "<prefix1>=<href1> <prefix2>=href2> ..." format
However my XPath perl command seems to contradict the above:
% xpath -e "//SOAP-ENC:Array[@id='ref-297']" SR_ADULT_007.ExamCard > /dev/null
Found 1 nodes in SR_ADULT_007.ExamCard:
-- NODE --
What did I misunderstood from libxml2/xpath/namespace convention ?
The correct syntax for xpath1 example is simply (thanks Conal!):
% ./xpath1 SR_ADULT_007.ExamCard "//SOAP-ENC:Array[@id='ref-297']" SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/
Result (1 nodes):
= element node "http://schemas.xmlsoap.org/soap/encoding/:Array"