Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: A (simple) XPath Question.

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 12/6/2008 4:40:00 PM
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/view.phtml/aid/34022/fid/1753 for 
some examples.

-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent