hey guys, iam using the libaray ArrayToXml. i want to be able to tell the converter IF THE ARRAY ELEMENT IS EMPTY DON'T CONVERT IT TO XML.
Example:
The 'password' is empty in this array
{
"firstName": "Chuck",
"lastName": "Norris",
"age": 75,
"bio": "Roundhouse kicking asses since 1940",
"password": ""
}
and it convert to this
<?xml version="1.0" encoding="UTF-8"?>
<root>
<firstName>Chuck</firstName>
<lastName>Norris</lastName>
<age>75</age>
<bio>Roundhouse kicking asses since 1940</bio>
<password></password>
</root>
what i want is this. so the 'password element gone'
<?xml version="1.0" encoding="UTF-8"?>
<root>
<firstName>Chuck</firstName>
<lastName>Norris</lastName>
<age>75</age>
<bio>Roundhouse kicking asses since 1940</bio>
</root>
so i use the ArrayToXML package.
i can't figure it out. here is my convert function
public function show(Configuration $configuration)
{
$result = ArrayToXml::convert($configuration->data, 'root', true, 'UTF-8');
return response($result)->header('Content-Type', 'text/xml');
}
Maybe i have to do something in the ArrayToXml.php file. from: https://github.com/spatie/array-to-xml