I'm having an issue getting at a particular namespace value using Simple XML.
Here's a snippet from the XML file:
<message xmlns:blend="http://www.blendlabs.com"
xmlns:ulad="http://www.datamodelextension.org/Schema/ULAD"
xmlns="http://www.mismo.org/residential/2009/schemas"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xlink="http://www.w3.org/1999/xlink"
targetnamespace="http://www.mismo.org/residential/2009/schemas">
<deal_sets>
<deal_set>
<deals>
<deal>
<loans>
<loan loanroletype="SubjectLoan" sequencenumber="1" xlink:label="LOAN_1">
<extension>
<other>
<blend:loan xlink:label="LOAN_1_BLEND_EXTENSION">
<blend:marketing_items>
<blend:marketing_item>
<blend:marketingtypevalue>DirectMarketingCode</blend:marketingtypevalue>
<blend:marketingvalue>google.com</blend:marketingvalue>
</blend:marketing_item>
</blend:marketing_items>
</blend:loan>
</other>
</extension>
</loan>
</loans>
</deal>
</deals>
</deal_set>
</deal_sets>
</message>
The value I'm trying to get would be google.com
from the blend:marketingvalue
field at the end of the snippet.
I can access non-namespace values just fine but I don't really get how to access the nested namespace values for the blend
fields.
Here is the code I am try to use:
$xml = simplexml_load_string($body);
$blend = $xml->children('http://www.blendlabs.com');
$marketing_value = $xml->DEAL_SETS->DEAL_SET->DEALS->DEAL->LOANS->LOAN->EXTENSION->OTHER->$blend->LOAN->MARKETING_ITEMS->MARKETING_ITEM->MARKETINGVALUE;
echo $marketing_value; // just echo's nothing currently.
So I guess my question is, how do you format it to access nested objects?
Do I need to put the $blend variable in front of each object item?
Is that even how you are supposed to use the children
function?
Any help would be much appreciated.