有可能simpleXML
解析foreach“categories”->所有“subCategories1”节点(不仅是每个“categories”中的第一个)?
示例:需要在subcategories2之后进入subcategories1之后在subcategories3之后,在subcategories2->subcategories3中返回,如果没有更多subcategories2进入subcategories1,如果该分类节点没有subcategories1则执行下一个。
<xml>
<categories>
<tag11>value</tag11>
<tag12>value</tag12>
<subCategories1>
<tag21>value</tag21>
<tag22>value</tag22>
<subCategories2>
<!-- ........ -->
<tag31>....</tag31>
</subCategories2>
</subCategories1>
</categories>
<categories>
<subCategories1>
<!-- ............... -->
</subCategories1>
<subCategories1>
<!-- ............... -->
</subCategories1>
</categories>
<!-- ....... -->
<categories>
<!-- ............ -->
</categories>
</xml>
foreach($xml->Categories as $categories){
foreach ($categories->SubCategories1 as $cat => $value){
//this took only the first SubCategories1 node from all Categories tag...
}
}
ps我的英语有点生疏。只是为了清楚我需要进入第一个“类别”标签,这里进入“subcategory1”这里“subcategory2”这里所有“subcategoory3”在下一个“subcategory2”中返回一个级别如果存在..如果不进入“子类别1”中的另一个级别,如果存在,则执行相同的规则,否则转到下一个“类别”标签。