本文介绍了的':'字符,十六进制值0x3A,不能包含在名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含像
<ab:test>Str</ab:test>
当我试图用code访问它:
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:服务器无法处理请求。 ---> System.Xml.XmlException:在':'字符,十六进制值0x3A,不能被包含在一个名称
我应该如何访问它?
推荐答案
如果你想使用命名空间,的LINQ to XML使这很容易:
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();
寻找一个的xmlns:AB = ...
部分文档中找出哪些命名空间URIAB是指
Look for an xmlns:ab=...
section in your document to find out which namespace URI "ab" refers to.
这篇关于的':'字符,十六进制值0x3A,不能包含在名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!