Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The ':' character, hexadecimal value 0x3A, cannot be included in a name

I have an xml file that contains its element like

<ab:test>Str</ab:test>   

When I am trying to access it using the code:

XElement tempElement = doc.Descendants(XName.Get("ab:test")).FirstOrDefault(); 

It's giving me this error:

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Xml.XmlException: The ':' character, hexadecimal value 0x3A, cannot be included in a name.

How should I access it?

like image 994
coure2011 Avatar asked Apr 04 '10 19:04

coure2011


1 Answers

If you want to use namespaces, LINQ to XML makes that really easy:

XNamespace ab = "http://whatever-the-url-is"; XElement tempElement = doc.Descendants(ab + "test").FirstOrDefault(); 

Look for an xmlns:ab=... section in your document to find out which namespace URI "ab" refers to.

like image 108
Jon Skeet Avatar answered Sep 21 '22 13:09

Jon Skeet