Subject:XPath query doesnot work if xml has namespace declaration Author:Manikandan Surendranath Date:06 Apr 2005 06:57 AM
I have an xml exported from MS-Excel. I opened it in SS and gave the XPath query "/Workbook/Worksheet/Table" the query resulted with no hits.
However if remove the namespace declaration from the root node, i.e.
Subject:XPath query doesnot work if xml has namespace declaration Author:(Deleted User) Date:06 Apr 2005 07:52 AM
XPath 1.0 does not use default namespaces (see http://www.w3.org/TR/xpath#node-tests,
"A QName in the node test is expanded into an expanded-name using the namespace
declarations from the expression context. This is the same way expansion is
done for element type names in start and end-tags except that the default
namespace declared with xmlns is not used: if the QName does not have a prefix,
then the namespace URI is null"), so writing "/Workbook" will not match
the <Workbook xmlns="..."> element in your XML.
The correct XPath query is "/ss:Workbook/ss:Table....."