I m reading a XML file in a very simple way:
XmlTextReader reader = new XmlTextReader(dataPath);
while(reader.Read()){
switch (reader.Name){
case "language":
Debug.Log(reader.ReadString());
break;
case "file":
Debug.Log(reader.ReadString());
break;
case "arg":
Debug.Log(reader.ReadString());
break;
}
}
我的xml喜欢:
<?xml version="1.0" encoding="ISO-8859-1"?>
<config>
<language>EN-US</language>
<file>FileDocsample.txt</file>
</config>
<data>
<arg>LKR</language>
</dara>
我的第一个问题是:
XmlException: Multiple document element was detected. file:///C:/prj/as/sample.xml Line 7, position 2.
Mono.Xml2.XmlTextReader.ReadStartTag ()
Mono.Xml2.XmlTextReader.ReadContent ()
Mono.Xml2.XmlTextReader.Read ()
System.Xml.XmlTextReader.Read ()
LectorXML.Start () (at as/sampleXML.cs:17)
第二,我的产出是语言和档案,但诺尔。 或许是因为情况不同? 如何解决这一问题?