当我尝试从 stringReader 加载 XDocument 时,出现此错误:System.Xml.XmlException: The '=' character, hexadecimal value 0x3D, cannot be included in a name. Line 1, position 496. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(String res, String[] args) at System.Xml.XmlTextReaderImpl.ParseElement() at System.Xml.XmlTextReaderImpl.ParseElementContent() at System.Xml.XmlTextReaderImpl.Read() at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r) at System.Xml.Linq.XContainer.ReadContentFrom(XmlReader r, LoadOptions o) at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options) at System.Xml.Linq.XDocument.Load(TextReader textReader, LoadOptions options) at Rextester.Program.Main(String[] args)下面是我正在尝试加载的一段代码: public class Program { public static void Main(string[] args) { String body = "<ContactBundleMaintainRequestMessage_sync><BasicMessageHeader><ID>b4cf2093e85242259f0b1b9122b75210</ID></BasicMessageHeader><Contact><UUID>4211feec-464c-4bd8-9490-f1041ed95504</UUID><LifeCycleStatusCode>2</LifeCycleStatusCode><GivenName>Carlo</GivenName><MiddleName /><FamilyName>DiBrigida</FamilyName><Relationship><RelationshipBusinessPartnerUUID>00163e11-a664-1ee8-85c3-74c6366e0886</RelationshipBusinessPartnerUUID><RoleCode>BUR027-2</RoleCode></Relationship><GroupwareSubscriptionactionCode="04"><EmployeeUUID>00163e11-a664-1ee8-85c3-74c6366e0886</EmployeeUUID></GroupwareSubscription></Contact></ContactBundleMaintainRequestMessage_sync>"; StringReader read = new StringReader(body); XDocument xDoc = XDocument.Load(read); } }你能帮我解决这个问题吗?我用谷歌搜索了很多,但没有得到任何解决方案或解释到底哪里出了问题
1 回答
![?](http://img1.sycdn.imooc.com/545847f50001126402200220-100-100.jpg)
弑天下
TA贡献1818条经验 获得超8个赞
属性必须与标签名称用空格分隔: <GroupwareSubscriptionactionCode="04">
应该是<GroupwareSubscription actionCode="04">
。
- 1 回答
- 0 关注
- 1019 浏览
添加回答
举报
0/150
提交
取消