Seek XPath Expression

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gimme_this_gimme_that@yahoo.com

    Seek XPath Expression

    This may be so easy no one responds.

    What is the XPath expression that fetches the value PPV - the
    PersistentTicke t?

    The namespace thing is throwing me off.

    Thanks.

    <?xml version="1.0" encoding="utf-8"?><soap:Envel ope
    xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/"
    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http ://www.w3.org/2001/
    XMLSchema"><soa p:Header><Compa nyAuthHeader xmlns="http://
    webservices.mon ster.com/MonsterPortal"> <PersistentTick et>PPV</
    PersistentTicke t>
    </CompanyAuthHead er>
    </soap:Header>
    <soap:Body>
    <AuthenticateBy CompanyAccessTi cketResponse xmlns="http://ws.com/VX">
    <AuthenticateBy CompanyAccessTi cketResult>true </
    AuthenticateByC ompanyAccessTic ketResult>
    </AuthenticateByC ompanyAccessTic ketResponse>
    </soap:Body>
    </soap:Envelope>

  • pr

    #2
    Re: Seek XPath Expression

    gimme_this_gimm e_that@yahoo.co m wrote:
    This may be so easy no one responds.
    >
    What is the XPath expression that fetches the value PPV - the
    PersistentTicke t?
    >
    The namespace thing is throwing me off.
    >
    Thanks.
    >
    <?xml version="1.0" encoding="utf-8"?><soap:Envel ope
    xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/"
    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http ://www.w3.org/2001/
    XMLSchema"><soa p:Header><Compa nyAuthHeader xmlns="http://
    webservices.mon ster.com/MonsterPortal"> <PersistentTick et>PPV</
    PersistentTicke t>
    </CompanyAuthHead er>
    </soap:Header>
    <soap:Body>
    <AuthenticateBy CompanyAccessTi cketResponse xmlns="http://ws.com/VX">
    <AuthenticateBy CompanyAccessTi cketResult>true </
    AuthenticateByC ompanyAccessTic ketResult>
    </AuthenticateByC ompanyAccessTic ketResponse>
    </soap:Body>
    </soap:Envelope>
    >
    The most efficient would be:

    /soap:Envelope/soap:Header/
    monster:Company AuthHeader/monster:Persist entTicket/text()

    where you have declared (by whatever means appropriate in the tool
    you're using)

    xmlns:soap="htt p://schemas.xmlsoap .org/soap/envelope/"
    xmlns:monster=" http://webservices.mon ster.com/MonsterPortal"


    You could also do:

    //monster:Persist entTicket/text()

    or (without declaring the namespaces):

    //*[local-name() = 'PersistentTick et' and namespace::node ()[. =
    'http://webservices.mon ster.com/MonsterPortal']]/text()

    Comment

    • pr

      #3
      Re: Seek XPath Expression

      pr wrote:
      //*[local-name() = 'PersistentTick et' and namespace::node ()[. =
      'http://webservices.mon ster.com/MonsterPortal']]/text()
      Sorry. Should be:

      //*[local-name() = 'PersistentTick et' and namespace-uri() =
      'http://webservices.mon ster.com/MonsterPortal']/text()

      Comment

      • gimme_this_gimme_that@yahoo.com

        #4
        Re: Seek XPath Expression

        On Jun 12, 4:27 am, pr <p...@porl.glob alnet.co.ukwrot e:
        pr wrote:
          //*[local-name() = 'PersistentTick et' and namespace::node ()[. =
            'http://webservices.mon ster.com/MonsterPortal']]/text()
        >
        Sorry. Should be:
        >
           //*[local-name() = 'PersistentTick et' and namespace-uri() =
             'http://webservices.mon ster.com/MonsterPortal']/text()
        This worked perfectly. Thanks Pr.

        I'm using Java (org.jdom.xpath .XPath) which has the following method:

        addNamespace(ja va.lang.String prefix, java.lang.Strin g uri)
        which adds a namespace definition (prefix and URI) to the list of
        namespaces known of this XPath expression.

        My this case, what are the values of prefix and uri?

        Thanks.


        Comment

        • pr

          #5
          Re: Seek XPath Expression

          gimme_this_gimm e_that@yahoo.co m wrote:
          I'm using Java (org.jdom.xpath .XPath) which has the following method:
          >
          addNamespace(ja va.lang.String prefix, java.lang.Strin g uri)
          which adds a namespace definition (prefix and URI) to the list of
          namespaces known of this XPath expression.
          >
          My this case, what are the values of prefix and uri?
          The prefix is up to you, provided you don't repeat a prefix already used
          in your document (e.g. 'soap'), start the prefix with a letter or
          underscore, and confine yourself to the characters

          A-Z a-z 0-9 _ - .

          (or consult <URL: http://www.w3.org/TR/xml-namesfor the full range of
          permissible characters, software permitting).

          Without knowing Java in any detail, I presume

          addNamespace("m onster",
          "http://webservices.mon ster.com/MonsterPortal")

          is appropriate if you want to use

          monster:Persist entTicket

          in your XPath, and

          addNamespace("m ", "http://webservices.mon ster.com/MonsterPortal")

          if you want to use

          m:PersistentTic ket

          The significant thing about the namespace is its URI - you could add the
          namespace twice and use the prefixes interchangeably , although that
          might be unnecessarily confusing :-)

          Comment

          Working...