Reputation: 30906
I have an xml string below that I've turned into an object using
$content = mb_convert_encoding($content, "ASCII");
$obj = new SimpleXMLElement($content);
The structure of obj is perfectly matching the xml. However trying to get an array of sets without the parent "set" node is causing me issues. I do
foreach($obj->group as $currentGroup)
{
From inside here if I do $currentGroup->sets I then see a set node with numbering under it, 0 and 1, and under it the structure of the subtest.
My problem is it I try to do $currentGroup->sets->set (to try to get an array of sets without the parent then I get the first set automatically and none of the others ones.
<global>
<group name="bce">
<sets>
<set name="a">
<subsets>
<subset name="bla"/>
<subset name="bla2"/>
<subset name="bla3"/>
</subsets>
</set>
<set name="b" />
<subsets>
<subset name="bla"/>
<subset name="bla2"/>
<subset name="bla3"/>
</subsets>
</set>
<set name="c" />
<subsets>
<subset name="bla"/>
<subset name="bla2"/>
<subset name="bla3"/>
</subsets>
</set>
<set name="d" />
<subsets>
<subset name="bla"/>
<subset name="bla2"/>
<subset name="bla3"/>
</subsets>
</set>
</subgroupones>
</group>
<group name="ert">
<sets>
<set name="aa">
<subsets>
<subset name="bla"/>
<subset name="bla2"/>
<subset name="bla3"/>
</subsets>
</set>
<set name="bb" />
<subsets>
<subset name="bla"/>
<subset name="bla2"/>
<subset name="bla3"/>
</subsets>
</set>
</subgroupones>
</group>
</global>
Upvotes: 0
Views: 66
Reputation: 69681
So you want an array of the set nodes? Should be $currentGroup->sets->children()
unless I'm missing something.
Upvotes: 1