I am creating a language translation using XML by id
XML:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<word id="1">Word1_English</word>
<word id="2">Word2_English</word>
<word id="3">Word3_English</word>
<word id="10001">Word1_French</word>
<word id="10002">Word2_French</word>
<word id="10003">Word3_French</word>
<word id="20001">Word1_Chinese</word>
<word id="20002">Word2_Chinese</word>
<word id="20003">Word3_Chinese</word>
</root>
Code behind:
XmlDocument xmlDocument;
FileInfo fileInfo;
XmlNodeList xmlNodeList;
string xPath = "D:XMLLanguagePack.xml";
fileInfo = new FileInfo(xPath);
xmlDocument = new XmlDocument();
xmlDocument.Load(fileInfo.FullName);
xmlNodeList = xmlDocument.GetElementById("10001");
return xmlNodeList[0].InnerText; //should return 'Word1_French'
This code doesn't work, xmlNodeList
is null.
How can I get the content Word1_French?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…