【发布时间】:2017-12-22 18:32:18
【问题描述】:
我已经以编程方式编写了一个 xml 文档来存储一些数据,当我尝试将其加载回我在不同区域的应用程序中时,我的所有 Xmlnodes 都返回 null,即使我给它的节点名称是相同的。这使我无法提取每个节点的内部文本。
问题: 我错过了什么阻止我阅读这个 xml 文档
代码:
var xmlDocument = new XmlDocument();
xmlDocument.Load(@"\\mi\dfs\shared\Everyone\The Guy Technology\cavanaugh\OutageInformationDocument.xml");
XmlNode title = xmlDocument.SelectSingleNode("TitleTextvariable");
XmlNode type = xmlDocument.SelectSingleNode("TypeTextvaraible");
XmlNode information = xmlDocument.SelectSingleNode("InformationText");
XmlNode conference = xmlDocument.SelectSingleNode("ConferenceText");
XmlNode steps = xmlDocument.SelectSingleNode("StepsText");
XmlNode eta = xmlDocument.SelectSingleNode("EtaText");
XmlNode phone = xmlDocument.SelectSingleNode("PhoneMessageText");
XmlNode banner = xmlDocument.SelectSingleNode("BannerText");
XML 示例:
<OutageInfo>
<OutageInformation>
<OutageInfoitems>
<TitleTextvariable>title text</TitleTextvariable>
<TypeTextvaraible>info</TypeTextvaraible>
<InformationText>this is a test of the outage information</InformationText>
<ConferenceText>information</ConferenceText>
<StepsText>resolve it in this way</StepsText>
<EtaText>30 minutes</EtaText>
<PhoneMessageText>There is currently a phone message up</PhoneMessageText>
<BannerText>There is not currently a banner posted</BannerText>
</OutageInfoitems>
</OutageInformation>
</OutageInfo>
【问题讨论】: