【发布时间】:2013-12-20 18:23:37
【问题描述】:
我在编程时遇到了这个问题。对于每个特定的端口元素,我想检查<script> exixst。 <script> 是 <port> 节点元素的子元素。以这个例子为例,这里是图片的链接:
http://i.stack.imgur.com/T2FGr.png
// Leggi il file xml
XDocument xml = XDocument.Load(pathFile.Text);
var hosts = from h in xml.Descendants("address")
select new
{
addr = h.Attribute("addr").Value,
addrtype = h.Attribute("addrtype").Value
};
foreach (var host in hosts)
{
if (host.addrtype == "ipv4")
{
console.Text += host.addr + Environment.NewLine;
console.Text += host.addrtype + Environment.NewLine;
var ports = xml.Descendants("port");
foreach (var port in ports)
{
var script = port.Element("script");
var hasScriptElement = script != null;
?? -> how can i get the elem pem key value? thanks!!
}
}
}
【问题讨论】:
-
克里斯请张贴一些你的代码。没有它很难帮助你
-
向我们展示一些示例 xml。将我们需要知道的所有文本放在问题中,而不是放在场外的图片中。