I have a nested simple XML structure that I load with PHP's simpleXML. Some elements of the structure contain "context" attributes.
<tab context="new_item, edit_item">
<input type="text" context="new_item">
<input type="readonly" context="edit_item">
<tab context="new_item">
...
</tab>
</tab>
After loading, I need to clean the structure from all elements that do not belong to the current context.
I could of course traverse through each element but maybe somebody knows a quick, SimpleXML way - possibly with XPath - to filter the structure accordingly?
Note that "context" is a comma-separated list of values, however I could change that into a more parseable form:
context_new_item="yes" context_edit_item = "no"
if necessary.
I'm sifting through the simpleXML documentation myself now, it's just not the most expansive part of the PHP documentation...
Update: This post is hardly 13 minutes old, and already 2nd on Google for "simplexml filtering". Damn, I'm impressed.