-2
這是我的xml:爲什麼我不能讀取xml值?
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<el1>
<Id>1</Id>
</el1>
<el2>
<ip>1.2.3.4</ip>
<port>1</port>
</el2>
</Configuration>
我想讀這個代碼的值:
public ReadXml(string xmlPath)
{
try
{
XDocument xDoc = XDocument.Load(configFilePath);
XElement elm1 = xDoc.Element("el1"); // get elm1 == null
XElement elm2 = xDoc.Element("el2"); // get elm2 == null
}
catch (Exception e)
{
_log.Error("Fail to load", e);
}
}
}