Closed waspinator closed 4 years ago
Unfortunately the keyValue deserializer will only map elements from 1 namespace to the object, and ignore the rest.
However, since BatchEnvelope
and BatchContent
are in the same namespace, you can still manually hook up the mapping in each direction yourself.
Here's where mapValueObject
registers the Deserializer:
https://github.com/sabre-io/xml/blob/master/lib/Service.php#L247
You have access to the $elementMap
, so if you set the valueObject
deserializer yourself, you can give it a different third argument for the namespace.
Hope this helps!
So what would I change to the namespace
to ignore the AcRecBat
part of xmlns:AcRecBat
? Children aren't included in the Deserializer probably because they aren't part of the same namespace?
Playing around with the Atom example, and changing
<feed xmlns="http://www.w3.org/2005/Atom">
to
<AcRecBat:feed xmlns:AcRecBat="http://www.w3.org/2005/Atom">
breaks the Deserializer. Adding the AcRecBat:
to simple elements makes them work again
example:
<AcRecBat:title type="text">dive into mark</AcRecBat:title>
but adding them to object elements does not.
example
<AcRecBat:entry>
still returns []
for now simplexml_load_string
seems to do the job.
$xml_object = simplexml_load_string($xml_string);
$batch_envelope_object = $xml_object->BatchEnvelope;
$college_transcript_object = $xml_object->BatchContent->children('urn:org:pesc:message:CollegeTranscript:v1.4.0')->children();
I'm trying to parse an XML file with multiple namespaces. These are only applied to some parent-level elements, but not to their children. How would I define a service to accommodate this type of structure?
Using the Atom example as a template,
And creating a couple new classes
The parsed object doesn't have data from the children
Example XML: