CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2021
    Posts
    1

    Unhappy Xpath expression to extract value from a node/element

    Hi,

    Please see the xml below. I am trying to write an Xpath expression to retrieve the string value from the element "SessionID". The code I wrote,

    ./IDMResponse/Worker/SessionId/text()

    or

    ./WorkerID/SessionId/text()

    returns no value. Please help me with this.

    <?xml version="1.0" encoding="utf-8"?>
    <IDMResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="1" xmlns="http://www.nrf-arts.org/IXRetail/namespace/">
    <ARTSHeader>
    <MessageID>1</MessageID>
    <Response ResponseCode="Ok">
    <RequestID>1</RequestID>
    </Response>
    </ARTSHeader>
    <Worker MajorVersion="1" MinorVersion="0" FixVersion="1">
    <WorkerID>9968632a-fbb2-41a7011cab</WorkerID>
    <AllowedForBarcodeAuthentication>false</AllowedForBarcodeAuthentication>
    <LegalName><Name>jam</Name>
    <FullName>jam admin</FullName>
    </LegalName>
    <DisplayName>dax</DisplayName>
    <SecurityIdentifier TypeCode="UserName">jamadmin</SecurityIdentifier>
    <WorkLocation><HomeStore /></WorkLocation>
    <SessionId>194e7418-600e2b0fb</SessionId>
    <DaysToExpire>-1</DaysToExpire>
    </Worker>
    </IDMResponse>

  2. #2
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: Xpath expression to extract value from a node/element

    1. Please, post every code/script.xml block to be properly formatted and indented. Use Code tags for this.
    Example: you write:
    [CODE]some code ...
    indentation ...[/CODE]
    and we will see
    Code:
    some code ... 
        indentation ...
    2. You didn't provide any code "you wrote" to parse this xml.
    Victor Nijegorodov

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured