XML trying to get one value from xml

Hello,

I have some problems with getting single value from xml which is my request response variable caled pv!Resault(there are statusLine. statusCode, headers, contentyType and body). Im trying xathsnippet function but doesn't work. This is how expresson looks like xpathsnippet(pv!Result.body,"//DWDOCID") and it's stored in pv!docID (text type). I have to get DWDOCID value(in this case is 4422060)                                                          My xml response below

statusLine=HTTP/1.1 200 OK, statusCode=200, headers=[object Object], contentType=application/xml; charset=utf-8, body=<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="/DocuWare/Platform/Content/standard.xslt"?><DocumentIndexFields xmlns:s="">dev.docuware.com/.../services" xmlns="">dev.docuware.com/.../platform"><Field FieldName="DWDOCID" FieldLabel="Doc ID" ReadOnly="true"><Int>4422060</Int></Field><Field FieldName="DWDOCSIZE" FieldLabel="Document Size" ReadOnly="true"><Int>6450</Int></Field><Field FieldName="DWSTOREUSER" FieldLabel="Store User" ReadOnly="true"><String>APPIAN</String></Field><Field FieldName="DWSTOREDATETIME" FieldLabel="Store Date" ReadOnly="true"><DateTime>2020-02-12T10:12:44Z</DateTime></Field><Field FieldName="DWEXTENSION" FieldLabel="Extension" ReadOnly="true"><String>.png</String></Field><Field FieldName="DWMODUSER" FieldLabel="Modification User" ReadOnly="true"><String>APPIAN</String></Field><Field FieldName="DWMODDATETIME" FieldLabel="Modification Date" ReadOnly="true"><DateTime>2020-02-13T11:40:28Z</DateTime></Field><Field FieldName="DWSECTIONCOUNT" FieldLabel="File count" ReadOnly="true"><Int>1</Int></Field><Field FieldName="DWPAGECOUNT" FieldLabel="File count" ReadOnly="true"><Int>1</Int></Field><Field FieldName="NRKONTA" FieldLabel="Nr Konta"><String>123456</String></Field><Field FieldName="OPIS" FieldLabel="Opis"><String>-</String></Field><Field FieldName="WZÓR" FieldLabel="Wzór"><String>-</String></Field><Field FieldName="ODDZIAL" FieldLabel="Oddzial"><String>1234</String></Field><Field FieldName="NRKLIENTA" FieldLabel="Nr Klienta"><String>123456</String></Field><Field FieldName="USUNIETY" FieldLabel="USUNIETY" IsNull="true" /><Field FieldName="PLIKWENUS" FieldLabel="Plik_WENUS" IsNull="true" /><Field FieldName="LOGIN_AD" FieldLabel="LOGIN_AD" IsNull="true" /><Field FieldName="ID_ZGLOSZENIA_EZV" FieldLabel="ID zgloszenia EZV" IsNull="true" /><Field FieldName="ARCHIWKOD" FieldLabel="ARCHIWKOD" IsNull="true" /><Field FieldName="MODULOBGZ" FieldLabel="Modulo BGZ" IsNull="true" /><Field FieldName="KLASA_JAWNOSCI" FieldLabel="KLASA_JAWNOSCI" IsNull="true" /><Field FieldName="DOKUMENTY_DO_BRAKOWANIA" FieldLabel="DOKUMENTY_DO_BRAKOWANIA" IsNull="true" /><Field FieldName="OSOBA_FIZYCZNA" FieldLabel="OSOBA FIZYCZNA" IsNull="true" /><Field FieldName="REGON" FieldLabel="REGON" IsNull="true" /><Field FieldName="NAZWA_KLIENTA" FieldLabel="NAZWA KLIENTA" IsNull="true" /><Field FieldName="NRUNIKAT" FieldLabel="NRUNIKAT" IsNull="true" /><Field FieldName="GWID" FieldLabel="GWID" IsNull="true" /><Field FieldName="OKRES_PRZECHOWYWANIA" FieldLabel="OKRES_PRZECHOWYWANIA" IsNull="true" /><Field FieldName="DATADOKUMENTU" FieldLabel="Data Dokumentu" IsNull="true" /><Field FieldName="DATA_DO_BRAKOWANIA" FieldLabel="DATA_DO_BRAKOWANIA" IsNull="true" /><Field FieldName="DATA_ZAKONCZENIA_RELACJI" FieldLabel="DATA_ZAKONCZENIA_RELACJI" IsNull="true" /><Field FieldName="LEXMARK_ID" FieldLabel="LEXMARK_ID" IsNull="true" /><Field FieldName="DWDISK" FieldLabel="Disk Number" ReadOnly="true"><Int>6</Int></Field><Field FieldName="DWDISKNO" FieldLabel="Disk Number" ReadOnly="true"><Int>6</Int></Field></DocumentIndexFields>]

Thank you inadvance
Dawid

  • Is DWDOCID always first? If so, something like this might work: xpathsnippet(http!request.body,"//DocumentIndexFields/Field[1]/Int/text()","")

  • Hi David,

    Please refer the below post. Seems like the namespace is empty in the above xml code.

    https://community.appian.com/discussions/f/general/17695/parse-xml-response-with-xpathsnippet

  • 0
    A Score Level 2
    1 day ago in reply to dawids0001

    Hi

    Please check the below. Here i had added a namespace in the request you had shared above. Output will be 4422060

    load(
    local!a: "<DocumentIndexFields xmlns:s="&fn!char(34)&"">dev.docuware.com/.../services"&fn!char(34)&"">www.test.com/test xmlns="&fn!char(34)&"">dev.docuware.com/.../platform"&fn!char(34)&"><Field">www.test.com/test FieldName="&fn!char(34)&"DWDOCID"&fn!char(34)&" FieldLabel="&fn!char(34)&"Doc ID"&fn!char(34)&" ReadOnly="&fn!char(34)&"true"&fn!char(34)&"><Int>4422060</Int></Field><Field FieldName="&fn!char(34)&"DWDOCSIZE"&fn!char(34)&" FieldLabel="&fn!char(34)&"Document Size"&fn!char(34)&" ReadOnly="&fn!char(34)&"true"&fn!char(34)&"><Int>6450</Int></Field><Field FieldName="&fn!char(34)&"DWSTOREUSER"&fn!char(34)&" FieldLabel="&fn!char(34)&"Store User"&fn!char(34)&" ReadOnly="&fn!char(34)&"true"&fn!char(34)&"><String>APPIAN</String></Field><Field FieldName="&fn!char(34)&"DWSTOREDATETIME"&fn!char(34)&" FieldLabel="&fn!char(34)&"Store Date"&fn!char(34)&" ReadOnly="&fn!char(34)&"true"&fn!char(34)&"><DateTime>2020-02-12T10:12:44Z</DateTime></Field><Field FieldName="&fn!char(34)&"DWEXTENSION"&fn!char(34)&" FieldLabel="&fn!char(34)&"Extension"&fn!char(34)&" ReadOnly="&fn!char(34)&"true"&fn!char(34)&"><String>.png</String></Field><Field FieldName="&fn!char(34)&"DWMODUSER"&fn!char(34)&" FieldLabel="&fn!char(34)&"Modification User"&fn!char(34)&" ReadOnly="&fn!char(34)&"true"&fn!char(34)&"><String>APPIAN</String></Field><Field FieldName="&fn!char(34)&"DWMODDATETIME"&fn!char(34)&" FieldLabel="&fn!char(34)&"Modification Date"&fn!char(34)&" ReadOnly="&fn!char(34)&"true"&fn!char(34)&"><DateTime>2020-02-13T11:40:28Z</DateTime></Field><Field FieldName="&fn!char(34)&"DWSECTIONCOUNT"&fn!char(34)&" FieldLabel="&fn!char(34)&"File count"&fn!char(34)&" ReadOnly="&fn!char(34)&"true"&fn!char(34)&"><Int>1</Int></Field><Field FieldName="&fn!char(34)&"DWPAGECOUNT"&fn!char(34)&" FieldLabel="&fn!char(34)&"File count"&fn!char(34)&" ReadOnly="&fn!char(34)&"true"&fn!char(34)&"><Int>1</Int></Field><Field FieldName="&fn!char(34)&"NRKONTA"&fn!char(34)&" FieldLabel="&fn!char(34)&"Nr Konta"&fn!char(34)&"><String>123456</String></Field><Field FieldName="&fn!char(34)&"OPIS"&fn!char(34)&" FieldLabel="&fn!char(34)&"Opis"&fn!char(34)&"><String>-</String></Field><Field FieldName="&fn!char(34)&"WZÓR"&fn!char(34)&" FieldLabel="&fn!char(34)&"Wzór"&fn!char(34)&"><String>-</String></Field><Field FieldName="&fn!char(34)&"ODDZIAL"&fn!char(34)&" FieldLabel="&fn!char(34)&"Oddzial"&fn!char(34)&"><String>1234</String></Field><Field FieldName="&fn!char(34)&"NRKLIENTA"&fn!char(34)&" FieldLabel="&fn!char(34)&"Nr Klienta"&fn!char(34)&"><String>123456</String></Field><Field FieldName="&fn!char(34)&"USUNIETY"&fn!char(34)&" FieldLabel="&fn!char(34)&"USUNIETY"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"PLIKWENUS"&fn!char(34)&" FieldLabel="&fn!char(34)&"Plik_WENUS"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"LOGIN_AD"&fn!char(34)&" FieldLabel="&fn!char(34)&"LOGIN_AD"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"ID_ZGLOSZENIA_EZV"&fn!char(34)&" FieldLabel="&fn!char(34)&"ID zgloszenia EZV"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"ARCHIWKOD"&fn!char(34)&" FieldLabel="&fn!char(34)&"ARCHIWKOD"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"MODULOBGZ"&fn!char(34)&" FieldLabel="&fn!char(34)&"Modulo BGZ"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"KLASA_JAWNOSCI"&fn!char(34)&" FieldLabel="&fn!char(34)&"KLASA_JAWNOSCI"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"DOKUMENTY_DO_BRAKOWANIA"&fn!char(34)&" FieldLabel="&fn!char(34)&"DOKUMENTY_DO_BRAKOWANIA"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"OSOBA_FIZYCZNA"&fn!char(34)&" FieldLabel="&fn!char(34)&"OSOBA FIZYCZNA"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"REGON"&fn!char(34)&" FieldLabel="&fn!char(34)&"REGON"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"NAZWA_KLIENTA"&fn!char(34)&" FieldLabel="&fn!char(34)&"NAZWA KLIENTA"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"NRUNIKAT"&fn!char(34)&" FieldLabel="&fn!char(34)&"NRUNIKAT"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"GWID"&fn!char(34)&" FieldLabel="&fn!char(34)&"GWID"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"OKRES_PRZECHOWYWANIA"&fn!char(34)&" FieldLabel="&fn!char(34)&"OKRES_PRZECHOWYWANIA"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"DATADOKUMENTU"&fn!char(34)&" FieldLabel="&fn!char(34)&"Data Dokumentu"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"DATA_DO_BRAKOWANIA"&fn!char(34)&" FieldLabel="&fn!char(34)&"DATA_DO_BRAKOWANIA"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"DATA_ZAKONCZENIA_RELACJI"&fn!char(34)&" FieldLabel="&fn!char(34)&"DATA_ZAKONCZENIA_RELACJI"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"LEXMARK_ID"&fn!char(34)&" FieldLabel="&fn!char(34)&"LEXMARK_ID"&fn!char(34)&" IsNull="&fn!char(34)&"true"&fn!char(34)&" /><Field FieldName="&fn!char(34)&"DWDISK"&fn!char(34)&" FieldLabel="&fn!char(34)&"Disk Number"&fn!char(34)&" ReadOnly="&fn!char(34)&"true"&fn!char(34)&"><Int>6</Int></Field><Field FieldName="&fn!char(34)&"DWDISKNO"&fn!char(34)&" FieldLabel="&fn!char(34)&"Disk Number"&fn!char(34)&" ReadOnly="&fn!char(34)&"true"&fn!char(34)&"><Int>6</Int></Field></DocumentIndexFields>",
    xpathsnippet(local!a,"//DocumentIndexFields/Field[1]/Int/text()","")
    )

    Thanks,
    Vadivelan

 Discussion posts and replies are publicly visible