On Mon, Oct 15, 2007 at 09:17:08AM +0800, NageshS 70576 wrote: > 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,
I guess you are confused works perfectly: paphio:~/XML -> cat test.xml <?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> paphio:~/XML -> xmllint --shell test.xml / > xpath //Element1 Object is a Node Set : Set contains 1 nodes: 1 ELEMENT Element1 namespace xsi href=http://www.w3.org/2001/XMLSchema-instanc... ATTRIBUTE schemaLocation TEXT content=http://www.mypage.com/users/app/cfg D:\u... / > XPath in libxml2 doesn't care at all about any XSD. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ [EMAIL PROTECTED] | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ _______________________________________________ xml mailing list, project page http://xmlsoft.org/ [email protected] http://mail.gnome.org/mailman/listinfo/xml
