Is it possible to read values from below mentioned 2 xml documents using same code?

How can I extract orderID from below 2 documents using same code if anyone can suggest? same code for both…value will definitely be different each time>



Hi! use this below RegEx to get the orderID.




Lets assue the XML is deserialized with the Deserialize XML activity to the variable xDoc

A minimal implementation could look like this

Assign activity:
strOrderID =

(From xe In xDoc.Descendants()
Where  xe.Attributes.Select(Function (a) a.Name).Contains("orderID")
Select xe.Attribute("orderID").Value).FirstOrDefault

As an alternate, we can setup an approach based on the local name

(From xe In xDoc.Descendants()
Where  xe.Attributes.Any(Function (x) x.Name.LocalName.Equals("orderID"))
Select xe.Attribute("orderID").Value).FirstOrDefault

It’s not working… could u plz help

Please always tell us what was done and what is not achieved / error message.
Also can you share the XMLs for further inspections? Thanks for Support

MainDocument (9).zip (979 Bytes)

Let me clear the process:

  1. This xml document can contain either invoice ID or orderID or can contain both and the headers u can’t rely on here
  2. So how can we extract invoiceID and orderID both using a single code

Hope it clears. Sorry for the inconvenience. Plz help that would be really helpful

This is .xaml for what I tried… (2.5 KB)

Initial Requirement

looks like changed to

As the provided Code was aligned on the inital requirement for sure it will not work for an untold requirement.

Once you confirm, that requirement is fixed to:

we can start with checking some solution approaches.

Would a datable (key, value columnnames) work for you as a extraction result?

Actually it would be helpful if we can keep it to strings/ strings as I’ll also have to include the order id or invoice id in mails also.

That’s the only requirement. Thank you so much for helping

How about this approach for getting recognized which value was retrieved?

Can you share .xaml file if you don’t mind? That would e really helpful



(From a In xDoc.Descendants().SelectMany(Function (x) x.Attributes)
Where {"INVOICEID","ORDERID"}.Contains(a.Name.LocalName.toUpper)
Select s = String.Format("{0}:{1}",a.Name.LocalName, a.Value)).toArray

Find starter help here:
ppr_XMLBox_anjasing.xaml (6.1 KB)

1 Like

Thank you so much for the help :slight_smile: will try now

Thank you so much for helping so much. Just wanted to ask does this have any dependency on the code except retrieving invoice id and order id from the document?? Thanks :slight_smile:

for a better understanding of your question, may we ask you what is meant with dependencies?

  • packages: UiPath.WebApi.Activities for the XML Deserialization
  • filter terms: the array
  • imports: System.Xml, System.Xml.Linq, System.Linq

the LINQ is about:

  • check each xml attribute on its local name
  • filter out the attributes matching the local name defined in the array
  • use attribute local name and value for a particular info string per match

local name u mean: invoice id and order id right? I was referring to the code that u have shared what’s it dependency? (not the package)

Local name is about the XML name concept also handling namespaces

Oh Okay! Got that…Thanks for the clarification though! thank you so much :slight_smile:

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