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

Solution 1:

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.

Solution 2:

Try putting your namespace in { ... } like so:

string xfaNamespace = "{http://www.xfa.org/schema/xfa-template/2.6/}";

Solution 3:

I was having the same error. I found I was adding code...

var ab = "http://whatever-the-url-is";

... but ab was determined to be a string. This caused the error reported by OP. Instead of using the VAR keyword, I used the actual data type XNamespace...

XNamespace ab = "http://whatever-the-url-is";

... and the problem went away.

Solution 4:

There is an overload of the Get method you might want to try that takes into account the namespace. Try this:

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