I'm trying to access the value of the productType element using Simple Framework XML. However, the catch is that the parent element of that could be anything (ie abc1, abc2). I have seen some examples where it could be done with ElementUnion. However, those implementations require you to know the node value upfront. I was hoping to do it without knowing that.
It seems like SimpleXML doesn't support all the standard XPath features, so despite the below XPATH being valid, SimpleXML doesn't seem to like it. Any suggestions?
sample 1:
<?xml version="1.0" encoding="utf-8"?>
<t1>
<t11></t11>
<abc1>
<productType>APPLE</productType>
</abc1>
</t1>
sample 2:
<?xml version="1.0" encoding="utf-8"?>
<t1>
<t11></t11>
<abc2>
<productType>ORANGE</productType>
</abc2>
</t1>
Valid XPath, but SimpleXML does not like it:
/t1/*//productType[1]