【发布时间】:2016-12-07 15:31:17
【问题描述】:
<?xml version="1.0" encoding="UTF-8"?>
<EfxTransmit
xmlns="http://www.....abc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www....def http://www....ghi">
<EfxReport requestNumber="1" reportId="CNCONSUMERCREDITFILE">
<CNConsumerCreditReports>
....I only care about these
....I only care about these
....I only care about these
</CNConsumerCreditReports>
</EfxReport>
</EfxTransmit>
我创建了一个类似这样的对象架构:
[XmlRoot("CNConsumerCreditReports")]
public class Data
{
[XmlElement("CNConsumerCreditReport")]
public CNConsumerCreditReports CNConsumerCreditReports { get; set; }
}
但为了使该架构正常工作,我必须手动从 XML 字符串中删除以下内容及其结束标记
<EfxTransmit
xmlns="http://www.....abc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www....def http://www....ghi">
<EfxReport requestNumber="1" reportId="CNCONSUMERCREDITFILE">
但是,我发现手动删除这些标签很麻烦,我希望找到一种解决方法。我只是不知道是什么或如何。但我相信还有更好的方法。
感谢任何建议或截断的代码!
谢谢。
【问题讨论】: