我有像这样的xml:
<?xml version="1.0" encoding="utf-8" ?>
<response list="true">
<count>10748</count>
<post>
<id>164754</id>
<text></text>
<attachments list="true">
<attachment>
<type>photo</type>
<photo>
<pid>302989460</pid>
</photo>
</attachment>
</attachments>
我需要检查<attachment>
我的<post>
. 我收到所有这样的帖子:
XmlNodeList posts = XmlDoc.GetElementsByTagName("post");
foreach (XmlNode xnode in posts)
{
//Here I have to check somehow
}
如果帖子中没有<attachment>
节点,我想<text>
取而代之。