[xml] Query regarding Xpath
- From: NageshS 70576 <nageshs huawei com>
- To: xml gnome org
- Subject: [xml] Query regarding Xpath
- Date: Mon, 15 Oct 2007 09:17:08 +0800
Hi,
I am new to xpath. I am using Libxml2-2.6.28 version. I have a query regarding the xpath. My xml document
on which i use the xpath is like this,
<?xml version="1.0" encoding="UTF-8"?>
<Element1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mypage.com/users/app/cfg D:\usercfg.xsd">
<Element2 atrr1="true">
</Element2>
</Element1>
and my xpath query code is like this,
....
tree = xmlParseFile(filename);
ctxt = xmlXPathNewContext(tree->doc);
res = xmlXPathEval("//Element1", ctxt);
....
If i check the result for the number of nodes, it is showing 0 (res->nodesetval->nodeNr). However if i
change the input xml document to point like this,
<?xml version="1.0" encoding="UTF-8"?>
<Element1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="usercfg.xsd">
<Element2 atrr1="true">
</Element2>
</Element1>
Then the result set is correct. Is the usage of namespace in my document incorrect. Thanks in advance for
your reply.
Regards,
Nagesh.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]