【发布时间】:2010-10-25 23:00:58
【问题描述】:
http://www.dreamincode.net/forums/xml.php?showuser=335389
鉴于上面的 XML,如果每个子组都相同但值不同,我如何遍历“lastvisitors”元素内的每个元素?
//Load latest visitors.
var visitorXML = xml.Element("ipb").Element("profile").Element("latestvisitors");
所以现在我已经捕获了包含我需要的所有内容的 XElement。有没有办法循环遍历元素以获得我需要的东西?
我有一个名为 Visitor 的 POCO 对象,其唯一目的是保存必要的信息。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SharpDIC.Entities
{
public class Visitor
{
public string ID { get; set; }
public string Name { get; set; }
public string Url { get; set; }
public string Photo { get; set; }
public string Visited { get; set; }
}
}
再次感谢您的帮助。
【问题讨论】:
标签: c# xml linq-to-xml xelement