我如何通过 linq to xml 选择ip
和port
元素形成这个 xml 文件
<?xml version="1.0" encoding="utf-8"?>
<settings>
<IncomingConfig>
<ip>10.100.101.18</ip>
<port>5060</port>
</IncomingConfig>
<Device>
<username>tarek</username>
<AgentName>tarek</AgentName>
<password>ffff</password>
</Device>
<Device>
<username>adf</username>
<AgentName>adf</AgentName>
<password>fadsf</password>
</Device>
</settings>
我写了这段代码但不工作
XDocument doc = XDocument.Load(CONFIGURATION_FULL_PATH);
var port = int.Parse(doc.XPathSelectElement("port").Value);
var localIpAdres = doc.XPathSelectElement("ip").Value;