【发布时间】:2011-03-30 13:03:49
【问题描述】:
public Envio(int id)
{
XDocument xml = XDocument.Parse(LoadFromService(id));
ID = xml.Element("envio")
.Element("de").Value;
De = xml.Element("envio")
.Element("de").Value;
Para = xml.Element("envio")
.Element("para").Value;
Fecha = xml.Element("envio")
.Element("fecha").Value;
Descripcion = xml.Element("envio")
.Element("descripcion").Value;
}
/*
* <xml>
* <envio id="123">
* <de>Sergio</de>
* <para>Gabriela</para>
* <fecha>10/10/2010</fecha>
* <descripcion>Una moto de 30kg.</descripcion>
* </envio>
* </xml>
*/
我想提取所有信息以及根标签Envio的ID属性。
有什么帮助吗?
【问题讨论】:
标签: c# linq linq-to-xml xml-parsing