Re: A (simple) XPath Question.

Discussion in 'XML' started by Martin Honnen, Dec 6, 2008.

  1. 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/
    Martin Honnen, Dec 6, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marvin_123456

    "Memory leak" in javax.xml.xpath.XPath

    Marvin_123456, Jul 29, 2005, in forum: Java
    Replies:
    4
    Views:
    1,958
    jan V
    Jul 29, 2005
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,370
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Anna
    Replies:
    0
    Views:
    508
  4. goog
    Replies:
    0
    Views:
    496
  5. Tjerk Wolterink

    XPath: efficiency in xpath expressions

    Tjerk Wolterink, Nov 13, 2004, in forum: XML
    Replies:
    1
    Views:
    1,612
    Richard Tobin
    Nov 13, 2004
Loading...

Share This Page