【发布时间】:2012-02-02 20:03:06
【问题描述】:
我得到了如下的 XML 格式字符串:
<?xml version="1.0"?>
<tcm:ListKeywords xmlns:tcm="http://www.tridion.com/ContentManager/5.0" Managed="1024">
<tcm:Item ID="tcm:229-552514-1024" Type="1024" Title="Aalborg" Lock="0" IsRoot="true"/>
<tcm:Item ID="tcm:229-552512-1024" Type="1024" Title="Aarhus" Lock="0" IsRoot="true"/>
<tcm:Item ID="tcm:229-329379-1024" Type="1024" Title="Aberdeen" Lock="0" IsRoot="true"/>
<tcm:Item ID="tcm:229-569711-1024" Type="1024" Title="Abha" Lock="0" IsRoot="true"/>
<tcm:Item ID="tcm:229-192866-1024" Type="1024" Title="Abidjan" Lock="0" IsRoot="true"/>
<tcm:Item ID="tcm:229-569704-1024" Type="1024" Title="Abilene" Lock="0" IsRoot="true"/>
<tcm:Item ID="tcm:229-192850-1024" Type="1024" Title="Abu Dhabi" Lock="0" IsRoot="true"/>
<tcm:Item ID="tcm:229-192888-1024" Type="1024" Title="Accra" Lock="0" IsRoot="true"/>
</tcm:ListKeywords>
现在我有字符串的 Arraylist,我想编写一个函数,它将上面的 XML 字符串作为参数以及我的 Arraylist 字符串,并将与 XML //Item Title 属性匹配,例如如下:
public bool matchArrayWithXMLTitle(Xmldocument xDoc, string str)
{
If (//Item/Title == str)
return true;
else
return false;
}
然后我将使用它作为下面的代码
bool matchStr = matchArrayWithXMLTitle(xDoc,"Abidjan"); //应该返回true,因为Abidjan在XML中
请推荐!!
【问题讨论】: