huikm
October 10th, 2002, 02:52 AM
hi,
i am using MSXML4. I am now implementing schema validation into my XML document. Prior to introducing namespace and xml schema, all the xpath expressions work fine. Once i inserted the xmlns into the xml document root tag, all the XPath expressions failed.
is there something that i am missing or that with namespace, the Xpath expression needs to be more precise or something?
for example:
<?xml version="1.0" ?>
<ROOT>
<TEST dt="2002-10-10" />
<ROOT>
Xpath expression such as "//TEST" works
after introducing namespace and schema validation,
<?xml version="1.0" ?>
<ROOT xmlns="http://www.mynamespace.com" >
<TEST dt="2002-10-10" />
<ROOT>
Xpath expression "//TEST" returns error
code sample:
MSXML2::IXMLDOMElementPtr spRootElem = m_spXmlDoc->documentElement;
MSXML2::IXMLDOMNodePtr spNode = spRootElem->selectSingleNode(_bstr_t(_T("//TEST") ) );
ASSERT (spNode !=NULL);
Appreciate some help here.. thanks
meng
i am using MSXML4. I am now implementing schema validation into my XML document. Prior to introducing namespace and xml schema, all the xpath expressions work fine. Once i inserted the xmlns into the xml document root tag, all the XPath expressions failed.
is there something that i am missing or that with namespace, the Xpath expression needs to be more precise or something?
for example:
<?xml version="1.0" ?>
<ROOT>
<TEST dt="2002-10-10" />
<ROOT>
Xpath expression such as "//TEST" works
after introducing namespace and schema validation,
<?xml version="1.0" ?>
<ROOT xmlns="http://www.mynamespace.com" >
<TEST dt="2002-10-10" />
<ROOT>
Xpath expression "//TEST" returns error
code sample:
MSXML2::IXMLDOMElementPtr spRootElem = m_spXmlDoc->documentElement;
MSXML2::IXMLDOMNodePtr spNode = spRootElem->selectSingleNode(_bstr_t(_T("//TEST") ) );
ASSERT (spNode !=NULL);
Appreciate some help here.. thanks
meng