If I have three datasets, say:
<note><from>Me</from><to>someone</to><message>hello</message></note>
<note><from>Me</from><to></to><message>Need milk & eggs</message></note>
<note><from>Me</from><message>Need milk & eggs</message></note>
and I use simplexml, is there a simple xml way to check that there is a blank / missing tag automatically?
I would like the result to be:
FROM TO MESSAGE
Me someone hello
Me NULL Need milk & eggs
Me NULL Need milk & eggs
Now I am doing this manually, and I quickly realized that long xml files would take a very long time.
My current code example:
$xml = simplexml_load_string($string);
if ($xml->from != "") {$out .= $xml->from."\t"} else {$out .= "NULL\t";}
Sometimes the order is different from the other, maybe xml with:
<note><message>pick up cd</message><from>me</from></note>
therefore iterating through children and checking by index do not work.
The actual xml files I'm working with are thousands of lines each, so I obviously can't just encode in each tag.
source
share