我有一个问题,使用Linq XML分析以下XML。我正在做的是让元素检查是否它是我想要的,然后移动到下一个。我很确定它与xmlns有关,但我需要这个代码来处理这个风格和正常风格的RSS提要(没有xmlns)。有任何想法吗?问题解析RSS xml
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
<channel rdf:about="http://someurl.com">
<title>sometitle</title>
XElement currentLocation = startElementParameter;
foreach (string x in ("channel\\Title").Split('\\'))
{
if (condition1 == false)
{
continue;
}
else if (condition2 == false)
{
break;
}
else
{
// This is returning null.
currentLocation = currentLocation.Element(x);
}
}
谢谢!
编辑:XML没有粘贴正确。