我正在尝试从 C# 中的 xml 文件中读取某个部分。我在这里尝试使用此代码,但在 in 下出现编译器错误Text
,XmlNodeType.Text
但奇怪的是它与智能感知一起出现,并与其他所有内容(如等)给出相同的错误Element
。Comment
我错过了什么?
XmlTextReader reader = new XmlTextReader(xmlDoc);
List<string> paths = new List<string>();
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "Paths")
foreach(XmlNodeType.Text aa in reader.ReadInnerXml())
paths.Add(aa);
}
reader.Close();
XML 文件
<Config>
<Paths>
<Input>C:\</Input>
<Output>C:\</Output>
<Log>\Logs</Log>
</Paths>
<SystemOwnerRoles>
<Supplier>SUPPLIER</Supplier>
<Mop>MOP</Mop>
</SystemOwnerRoles>
</Config>