最近发现几个贴子都是问关于对XML的属性或元素进行模糊搜索的方法,在此发出代码片段示例,希望能够对你有所帮助;)
示例XML
private var xml:XML=
<employees>
<employee>
<name>Christina Coenraets</name>
<phone>555-219-2270</phone>
<email>ccoenraets@fictitious.com</email>
<active>true</active>
</employee>
<employee>
<name>Joanne Wall</name>
<phone>555-219-2012</phone>
<email>jwall@fictitious.com</email>
<active>true</active>
</employee>
<employee>
<name>Maurice Smith</name>
<phone>555-219-2012</phone>
<email>maurice@fictitious.com</email>
<active>false</active>
</employee>
<employee>
<name>Mary Jones</name>
<phone>555-219-2000</phone>
<email>mjones@fictitious.com</email>
<active>true</active>
</employee>
<employee>
<name>Jack Jones</name>
<phone>555-219-2000</phone>
<email>mjones@fictitious.com</email>
<active>true</active>
</employee>
</employees>
1.String检索法(区分大小写)
private function searchXML(index:String):XMLList{
return xml.employee.(name.indexOf(index)>-1)
}
private function searchXML(index:String):XMLList{
return xml.employee.(name.search(new RegExp(index,"gi"))>-1)
}1.正测检索法(不区分大小写)