none
xml RRS feed

  • Question

  • Hi,

    I am getting the below xml structure 

    <GetDocumentPropertiesResponse
    xmlns="http://123.com/DoService/Do"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <GetDocumentPropertiesResult>
    <Response>
    <Status>0</Status>
    <Text></Text>
    <Source></Source>
    <Version>V201409</Version>
    </Response>
    <Properties>
    <DocumentProperties>
    <DocId>c6837c98-c2f5-4a9b-a2b7-03671222d3e2al</DocId>
    <DocType>HRPICTURE</DocType>
    <MimeType>image/png</MimeType>
    <Description>gg</Description>
    <LastRevision>1</LastRevision>
    <LastUpdate>2018-03-20T17:18:42</LastUpdate>
    <IndexValues>
    <string>BL</string>
    <string>111</string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    </IndexValues>
    </DocumentProperties>
    <DocumentProperties>
    <DocId>1d01310f-cb98-4551-af14-fd650sdsd6da</DocId>
    <DocType>HRPICTURE</DocType>
    <MimeType>image/png</MimeType>
    <Description>hh</Description>
    <LastRevision>1</LastRevision>
    <LastUpdate>2018-03-20T17:17:36</LastUpdate>
    <IndexValues>
    <string>BL</string>
    <string>112</string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    <string></string>
    </IndexValues>
    </DocumentProperties>
    </Properties>
    </GetDocumentPropertiesResult>
    </GetDocumentPropertiesResponse>

    if string ="111" (ie <string>111</string>)

    then i need to pick and return node value of that document ie "DocId" value(c6837c98-c2f5-4a9b-a2b7-03671222d3e2al).


    I am new to xml please help.


    Regards, vishal



    • Edited by b vishal Friday, March 30, 2018 10:01 AM
    Friday, March 30, 2018 9:42 AM

All replies

  • Hi Vishal,

    For this requirement you need to use the xslt. Have you already tried any?


    Thanks, Girish R. Patil.

    Friday, March 30, 2018 10:08 AM
  • I am thinking to load xml document and pick the required value and return back to method, it will be easy for me to configure and work in scripting functoid.

    Regards, vishal

    Friday, March 30, 2018 10:24 AM
  • What have you tried?  In order to avoid duplicate or extraneous advice, it's best if you try a few things, then let us know what isn't working so we can provide specific guidance.

    Friday, March 30, 2018 12:28 PM
    Moderator
  • Hi Vishal,

    You can try following xPath. Please make sure to update the value for equal to (i.e. =) condition.

    /*[local-name()="GetDocumentPropertiesResponse" and namespace-uri()="http://123.com/DoService/Do"]/*[local-name()="GetDocumentPropertiesResult" and namespace-uri()="http://123.com/DoService/Do"]/*[local-name()="Properties" and namespace-uri()="http://123.com/DoService/Do"]/*[local-name()="DocumentProperties" and namespace-uri()="http://123.com/DoService/Do"][IndexValues[string='111']]/*[local-name()="DocId" and namespace-uri()="http://123.com/DoService/Do"]


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful.

    Monday, April 2, 2018 3:13 PM
  • Vishal, <o:p></o:p>

    you need to fix your response schema to not return empty Nodes and you can create separate schema to map your response schema to get the data if matching the condition using Value Mapping functoid  if string ="111"<o:p></o:p>

    Please refer this link will help to understand it.<o:p></o:p>

    https://docs.microsoft.com/en-us/biztalk/core/value-mapping-functoid<o:p></o:p>

    Thanks,

    Chandra

    Tuesday, April 3, 2018 8:17 PM
  • Looking at the document since <string> element is unbounded, it's best to use custom XSLT to do this.

    Thanks Arindam

    Wednesday, April 4, 2018 11:57 AM
    Moderator
  • This XPath will help you get what you want.

    //*[local-name()='DocumentProperties'][./*[local-name()='IndexValues']/*[local-name()='string'][2]='111']/*[local-name()='DocId']

    Regards.

    PS: The assumption here is that irrespective of the number of strings it is the second element that will contain the value to be tested.

    Wednesday, April 4, 2018 1:09 PM