Get certain attributes value from XML file


Im not too familiar with XML. Here’s the part of the XML-document:

I would like to get the value of the ‘native’ attribute in the ‘callid’ -element.

I have tried this on Write Line, after using the Deserialize Xml -Activity:
resultXML.Element(“callid”).Attribute(“native”).Value.ToString and many other variations of this. It doesn’t work. Only gives this error: Write line : Object reference not set to an instance of an object.

Is there a way I could get the value of the attribute quickly and easily with a command like that?

I have tried other solutions found on this forum, but they don’t wor for this file for some reason.

EDIT: also I’ve tried the execute XPath activity with: “//callid/@native
It gives the result as an Object-variable. Is there a way I could print that as a string?

1 Like


You can use XPATH.

Try something like this:



Thanks, but it doesn’t work for me.

What should be the TypeArgument in the For each -loop?

This is what it looks like:

Is there something wrong with my XPath command? The execution never even enters the for each loop. The variable ‘xmlValue’ is the result from the ‘Execute XPath’ activity.

The TypeArgument from For Each Loop must be “System.Xml.Linq.XElement

On the Execute XPath, try this: “recording filename/cti segmentnum

Then you use: “item.Element(“callid native”).Value.ToString()


1 Like

Have you tried this XPath:


I just tried this:

This was the xml on which i tried:

		<prop1 attrib1="val1" attrib2 = "val2" />
		<prop2 attrib1 = "Val1" /> content <prop2/>
		<prop1 attrib1="val11" attrib2 = "val21" />
		<prop2 attrib1 = "Val11" /> content2 <prop2/>
	<elem name = "name1">
		<prop1 attrib1="val1" attrib2 = "val2" />
		<prop2 attrib1 = "Val1" /> content <prop2/>

Got this result:


I have now. The XPath result is still an Object -variable. How do you print that? I tried result.ToString but it only prints this:

Thank you both for the help anyways!

1 Like

can you share the xml? i’ll try building the xpath for it

Unfortunately I cannot share the file. I’ve tried the Get XML Nodes and Get XML Node Attributes -activities and I was able to find the right attribute in a string format.

Thanks anyway for the help!

Hi Akhi, I would like to know how I write in the
Execute XPath to an xml field. Example in Picture:

Hello i am having the same error,
the process never enters the for
i try the xpath in this page a work for me

Hi, what did you write in the message box to get the output?
Execute XPath just leaves an Object.


hi I found a solution to these, here are some screenshots:

  1. they carry out the normal process and do the deserialization of the xml
  2. they need to get the XML namespace this case the brackets are necessary, followed in this way they can get the value of a label
1 Like