Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Re: A (simple) XPath Question.

Reply
Thread Tools

Re: A (simple) XPath Question.

 
 
Martin Honnen
Guest
Posts: n/a
 
      12-06-2008
Bubba wrote:

> <ItemInformation xmlns="http://tempuri.org/ItemInfo.xsd">
> <ItemDetails>
> <Title>This is the item title</Title>
> <State>This is the item state</State>
> <ItemCost ... />
> <ItemCost ... />
> <ReOrder>
> <MinLevel>25000</MinLevel>
> <MaxLevel ... />
> </ReOrder>
> </ItemDetails>
> </ItemInformation>
>
> The ItemInfo.xsd file does not exist. But how do I extract the Title
> element using XPath from this file? I've tried all manner of syntax but
> never get any results, can anyone help here please.


With the namespace declaration (xmlns="http://tempuri.org/ItemInfo.xsd")
in the XML document the ItemInformation element and its descendants are
in the namespace http://tempuri.org/ItemInfo.xsd. For XPath 1.0 to
select elements in a namespace you need to bind a prefix to the
namespace URI and use that prefix in the XPath expression to qualify
element names e.g.
/pf:ItemInformation/pf:ItemDetails/pf:Title
where the prefix pf is bound to the namespace URI
http://tempuri.org/ItemInfo.xsd.
How you bind a prefix to a namespace URI depends on the XPath API or
XPath host language (e.g. XSLT) you use. See
http://www.faqts.com/knowledge_base/...34022/fid/1753 for
some examples.

--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
XPath: efficiency in xpath expressions Tjerk Wolterink XML 1 11-13-2004 06:03 PM
Are there any XPath parsers that generate XPath trees? goog XML 0 01-14-2004 01:47 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments