Skip to main content
Solved

XMLFragmenter - How to expose only the first attribute

  • November 24, 2022
  • 4 replies
  • 37 views

Hi,

 

I am trying to expose an attribute from the _response_body returned from a http caller.

 

This is the response:

 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><s:Header><o:Security s:mustUnderstand="1" xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><u:Timestamp u:Id="_0"><u:Created>2022-11-24T11:20:34.572Z</u:Created><u:Expires>2022-11-24T11:25:34.572Z</u:Expires></u:Timestamp></o:Security></s:Header><s:Body><CreateWorksheetResponse xmlns="http://webservices.whitespacews.com/"><CreateWorksheetResult xmlns:a="http://webservices.whitespacews.com/API/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><CodeDescription>Success</CodeDescription><ErrorCode>0</ErrorCode><ErrorDescription>Success</ErrorDescription><SuccessFlag>true</SuccessFlag><a:WorksheetResponse xmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><b:anyType i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">129283</b:anyType><b:anyType i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema"/></a:WorksheetResponse></CreateWorksheetResult></CreateWorksheetResponse></s:Body></s:Envelope>

 

In bold is what i would like to expose.

 

I have set the elements to match anyType and attributes to expose to anyType.

 

The problem is that it returns two rows as there is two anyType attributes. I only need the first one.

 

any ideas on how i can ignore the second one? im not sure what it is used for as its never had any data in it.

 

Thank you.

 

Best answer by ebygomm

If you just need to get the value of that first element you could also use an XMLXQueryExtractor

declare namespace b='http://schemas.microsoft.com/2003/10/Serialization/Arrays';
//b:anyType[1]/text()

imageThis should return the value 129283

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

david_r
Celebrity
  • 8394 replies
  • November 24, 2022

You can use a Tester and check that the attribute "anyType" has a value. You'll have to expose "anyType" in the XMLFragmenter first:

imageYou'll also have to enable flattening:

imageFollowed by:

image 


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3435 replies
  • Best Answer
  • November 24, 2022

If you just need to get the value of that first element you could also use an XMLXQueryExtractor

declare namespace b='http://schemas.microsoft.com/2003/10/Serialization/Arrays';
//b:anyType[1]/text()

imageThis should return the value 129283


  • Author
  • 2 replies
  • November 24, 2022

If you just need to get the value of that first element you could also use an XMLXQueryExtractor

declare namespace b='http://schemas.microsoft.com/2003/10/Serialization/Arrays';
//b:anyType[1]/text()

imageThis should return the value 129283

Thank you, this is exactly what i was looking for.


  • Author
  • 2 replies
  • November 24, 2022

You can use a Tester and check that the attribute "anyType" has a value. You'll have to expose "anyType" in the XMLFragmenter first:

imageYou'll also have to enable flattening:

imageFollowed by:

image 

Thank you for the detailed response David. I ended up using the XMLXQueryExtractor in the end as if the httpcaller was to return an error it would mean that the first anyType would also be blank and i would not want to filter it out in that case as i do some error handling later on.