Get XML element value (with namespaces)

I’m trying to get element value using namespaces but i get this error: Message box : The ‘:’ character, hexadecimal value 0x3A, cannot be included in a name

1 Like

Hello, try to use “{ }” or if it’s dynamic which is like, “is dynamic :astonished:

XNamespace ab = "http://your-url";
XElement tempElement = doc.Descendants(ab + "xlvalue").FirstOrDefault();

this way it will look for an xmlns:ab=… section in your document to find out which namespace URI “ab” refers to.

You can get it by finding the attribute value for XNamespace.Xmlns + “ab”

let us knwo if this is the answer you are looking for :slight_smile:


Yes, thank you, I created variables Xnamespace and it worked!

1 Like

@Timber I have the same issue. How did you solve it?

Hello @Timber and @andnesper,

any suggestions how to fix it? Here’s my Code that does not work for the same reason: (43.7 KB)

Kind regards

You have to create XNamespace variables, I edited you xaml.

Main.xaml (6.1 KB)

Hi @Timber,

thanks for your reply. Actually it just Returns “System.activities” which means Nothing. I wanted to get the value of “x:class” which is “Main”.

So in this instance I was hoping to get “main”. Any help?

Thanks a lot

Hey @Gennaro_Bozza,

It was just an example to get something from XML using namespaces, it returns this:

In order to get “Main” you have to access ‘Activity’ element’s x:Class attribute:


Main.xaml (6.0 KB)


hi @Timber

thanks a lot for your really helpful reply! I am starting to understand well the mechanism. Yet, the following line does not work:

that I would like to use to obtain the DisplayName.

I have initialised “ui” with “clr-namespace:System.Collections.ObjectModel;assembly=mscorlib”. Maybe I should have initialised it with something else?

Furthermore, I would like to extract all of the workflow comprised within, for example, xmlDoc.Element(activities+“Activity”).Element(activities+“Sequence”). How can this be done?

Please let me know, your help is very appreciated.
Kind regards,

create XNamespace variables with these values:

So in this case ui = “

1 Like

I didn’t understand the second part, what exactly do you want to extract from this xml?

hi @Timber,

thanks! now it works well! As far as the workflow to extract is concerned, let’s assume the following:

<Element 1>
<Element 2>
<Element 3>
</Element 3>
</Element 2>
</Element 1>

Well, I would like to extract for example everything within Element 2, or Element 3 etc.

Any clues?
Many thanks

1 Like

Adding .ToString will give you all element as string: xmlDoc.Element(activities+“Activity”).Element(activities+“Sequence”).ToString =

Hi Timber,

I am trying to get element value .
But I am getting error as,
“Deserialize xml : ‘\’ is an unexpected token. The expected token is ‘"’ or ‘’'. Line 1, position 15.”,

My XML is,

<?xml version=\"1.0\" encoding=\"utf-8\"?>
<soap:Envelope xmlns:soap=\"\" xmlns:xsi=\"\" xmlns:xsd=\"\">
		<SearchSecretsByFolderResponse xmlns=\"\">
				<Errors />
					<SecretTypeName>Active Directory Account - Robotics</SecretTypeName>
					<SecretTypeName>Active Directory Account - Robotics</SecretTypeName>