Re: [xml] question on xml validtion and xpath
- From: Daniel Veillard <veillard redhat com>
- To: "Andric, Milan" <milan andric intel com>
- Cc: xml gnome org
- Subject: Re: [xml] question on xml validtion and xpath
- Date: Sat, 5 Aug 2006 05:10:06 -0400
On Fri, Aug 04, 2006 at 02:36:52PM -0700, Andric, Milan wrote:
[...]
Sample XML file:
<?xml version="1.0" encoding="utf-8" ?>
<TU xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com config.xsd">
<Model Name="Models">
</Model>
</TU>
[...]
Question: My Xpath Inquiry:
/TU/Model
returns no results - why is this and how can I make it so that both
That's normal. Your elements are in a namespace, the default namespace
defined in the instance (xmlns="http://www.w3schools.com") and in XPath
you must use a prefix in the query to access a namespaced node. The only
solution is to use /p:TU/p:Model and define a binding between p and
"http://www.w3schools.com" in the XPath context.
This is really a very very frequently asked XPath question, the one that
each and every beginner to XPath who doesn't learn from a book or a tutorial
get hit with (assuming one uses namespaces)
Daniel
--
Daniel Veillard | Red Hat http://redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]