我有一个看起来像这样的测试xml文件:
<Person>
<ContactInfo>
...
<ContactInfo>
</Person>
Run Code Online (Sandbox Code Playgroud)
当我尝试反序列化时,一切正常。但问题是有时这个xml文件的结构不同——有时添加xml命名空间。
<Person xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<ContactInfo>
...
<ContactInfo>
</Person>
Run Code Online (Sandbox Code Playgroud)
现在,当我进行序列化时,我收到 IOnvalidOperationException:“XML 文档 (1, 2) 中存在错误”。内部异常消息说<Person xmlns='http://tempuri.org/PaymentInformationXml.xsd'>不是预期的。
那么有人可以帮我解决这个问题吗?