Skip XML tag if other tag is not present


I have a XML that I would like to iterate through, and only assign where < SalesDocuments> exists.

<Soap:Envelope xmlns:Soap=“”>
<ReadMultiple_Result xmlns=“urn:microsoft”>
< DTorderkort>
< Key>28</ Key>
< Reg_No>xxx</ Reg_No>
< VIN>xxx</ VIN>
< SalesDocuments/>
</ DTorderkort>
< DTorderkort>
< Key>28;</ Key>
< Reg_No>xxx</ Reg_No>
< VIN>xxx</ VIN>
< SalesDocuments>
< Key>36</ Key>
< HeaderDocumentType>Order</ HeaderDocumentType>
< HeaderNo>100001</ HeaderNo>
</ Sales_List>
< Sales_List>
< Key>36</ Key>
< HeaderDocumentType>Order</ HeaderDocumentType>
< HeaderNo>100002</ HeaderNo>
</ Sales_List>

How do I skip the first and only do my assigns on the second ?

1 Like

Hi @Michaeljep
Instead of skipping you can do assign though the below post

Ashwin S

I’m not completely sure how to use decendants or the childs, so the post doesn’t quite help me in the way I would like.

The first < DTorderkort> doesn’t contain < Sales_Documents>, so I would like to skip those elements, and only do my three assign and the for each run through of the Sales docments on the second < DTorderkort>

the info on the first < DTorderkort> can be different to the second, so if Sales documents is empty look for the next.

However you have to pay attention to the namespace definition
you would fetch the < DTorderkort> with descendants, then you can proces e.g. filtering the no containing saledDocuments, .etc…

we can help you on this faster with an uploaded sample XML.

I dug a bit deeper and managed to achieve it by doing a “For each” on the < DTorderkort> containing a for each on the Sales Documents, this gives me the last occurrence of the DT order that contains sales documents.

Have a look on this prototyping showcasing

  • direct access 2 DTorderkort element
  • retrieving all DTorderkort elements, but filtering out DTorderkort NOT having Sales_List Element(s)

Kindly note: first DT has an empty SalesDocuments thats why it was alligned on the condition “having Sales_List”

However it can adopted to your needs, once you give more details

Demo XAML here
Michaeljep.xaml (10.9 KB)


Excellent, thanks for your time and help, great with the where() function.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.