- trim: documentation ( source)
- printf: documentation ( source)
<?php
//header('Content-Type: text/plain');
function createCSV($xml, $f = ''){
if(!$xml->hasChildNodes()){
if(trim($xml->nodeValue) !== '')
printf("Value: %s \n", $xml->nodeValue);
return;
}
foreach($xml->childNodes as $item)
createCSV($item, $f);
}
$xml = new \DomDocument();
$xml->loadXML('<root>
<item>
<idRef>W-125S3G-23-1</idRef>
<parentIdRef>No</parentIdRef>
<eshopIdRef>new_connection_isdn</eshopIdRef>
<subscriberId>No</subscriberId>
<psOfferReference>No</psOfferReference>
<title>Telephony ISDN BRA</title>
<description>No</description>
<ignoreProductLabelAndKeepSticky>No</ignoreProductLabelAndKeepSticky>
<phoneNumber>2431078247</phoneNumber>
<serviceCategory>TELEPHONY</serviceCategory>
<serviceType></serviceType>
<addressList>
<item>
<label>INSTALLATION ADDRESS</label>
<street>ΗΡ.ΑΛΒ.ΜΕΤΩΠΟΥ</street>
<streetNumber>20</streetNumber>
<postalCode>00000</postalCode>
<city>ΤΡΙΚΑΛΑ</city>
<province>ΤΡΙΚΑΛΩΝ</province>
<area>ΤΡΙΚΑΛΑ</area>
<poBox>No</poBox>
<sortOrderNo>0</sortOrderNo>
</item>
</addressList>
<hasUpsells>No</hasUpsells>
<visible>Yes</visible>
<children>
<item>
<idRef>W-125S3G-29-1</idRef>
<parentIdRef>W-125S3G-23-1</parentIdRef>
<eshopIdRef>No</eshopIdRef>
<subscriberId>No</subscriberId>
<psOfferReference>No</psOfferReference>
<title>Voice</title>
<description>No</description>
<ignoreProductLabelAndKeepSticky>No</ignoreProductLabelAndKeepSticky>
<phoneNumber>2431078247</phoneNumber>
<serviceCategory>TELEPHONY</serviceCategory>
<serviceType></serviceType>
<addressList>
<item>
<label>INSTALLATION ADDRESS</label>
<street>ΗΡ.ΑΛΒ.ΜΕΤΩΠΟΥ</street>
<streetNumber>20</streetNumber>
<postalCode>00000</postalCode>
<city>ΤΡΙΚΑΛΑ</city>
<province>ΤΡΙΚΑΛΩΝ</province>
<area>ΤΡΙΚΑΛΑ</area>
<poBox>No</poBox>
<sortOrderNo>0</sortOrderNo>
</item>
</addressList>
<hasUpsells>No</hasUpsells>
<visible>Yes</visible>
<children>
<item>
<idRef>W-125S3H-2L-1</idRef>
<parentIdRef>W-125S3G-29-1</parentIdRef>
<eshopIdRef>indirect_call_diversion</eshopIdRef>
<subscriberId>No</subscriberId>
<psOfferReference>No</psOfferReference>
<title>Έμμεση Εκτροπή Κλήσης</title>
<description><![CDATA[<P>Περιμένετε ένα σημαντικό τηλεφώνημα στο γραφείο σας, όμως πρέπει να γυρίσετε επειγόντως στο σπίτι; Τώρα τα τηλέφωνα αλλάζουν δρόμο και σας βρίσκουν. <B>Η Εκτροπή Κλήσεων</B> σας δίνει τη δυνατότητα να μεταφέρετε το αναμενόμενο τηλεφώνημα στο σπίτι σας ή σε όποιο άλλο τηλέφωνο εσείς επιθυμείτε.</P>]]></description>
<ignoreProductLabelAndKeepSticky>No</ignoreProductLabelAndKeepSticky>
<phoneNumber>2431078247</phoneNumber>
<serviceCategory>TELEPHONY</serviceCategory>
<serviceType></serviceType>
<addressList>
<item>
<label>INSTALLATION ADDRESS</label>
<street>ΗΡ.ΑΛΒ.ΜΕΤΩΠΟΥ</street>
<streetNumber>20</streetNumber>
<postalCode>00000</postalCode>
<city>ΤΡΙΚΑΛΑ</city>
<province>ΤΡΙΚΑΛΩΝ</province>
<area>ΤΡΙΚΑΛΑ</area>
<poBox>No</poBox>
<sortOrderNo>0</sortOrderNo>
</item>
</addressList>
<hasUpsells>No</hasUpsells>
<visible>Yes</visible>
</item>
<item>
<idRef>W-125S3G-2B-1</idRef>
<parentIdRef>W-125S3G-29-1</parentIdRef>
<eshopIdRef>No</eshopIdRef>
<subscriberId>No</subscriberId>
<psOfferReference>No</psOfferReference>
<title>White Pages Option</title>
<description>No</description>
<ignoreProductLabelAndKeepSticky>No</ignoreProductLabelAndKeepSticky>
<phoneNumber>2431078247</phoneNumber>
<serviceCategory>TELEPHONY</serviceCategory>
<serviceType></serviceType>
<addressList>
<item>
<label>INSTALLATION ADDRESS</label>
<street>ΗΡ.ΑΛΒ.ΜΕΤΩΠΟΥ</street>
<streetNumber>20</streetNumber>
<postalCode>00000</postalCode>
<city>ΤΡΙΚΑΛΑ</city>
<province>ΤΡΙΚΑΛΩΝ</province>
<area>ΤΡΙΚΑΛΑ</area>
<poBox>No</poBox>
<sortOrderNo>0</sortOrderNo>
</item>
</addressList>
<hasUpsells>No</hasUpsells>
<visible>Yes</visible>
</item>
<item>
<idRef>W-125S3I-3G-1</idRef>
<parentIdRef>W-125S3G-29-1</parentIdRef>
<eshopIdRef>ote_service</eshopIdRef>
<subscriberId>No</subscriberId>
<psOfferReference>No</psOfferReference>
<title>OTE Service</title>
<description><![CDATA[<P>Για να έχετε δωρεάν επίσκεψη τεχνικού στο σπίτι σας και επί τόπου επισκευή, προσωρινή ή άμεση αντικατάσταση της τηλεφωνικής σας συσκευής, ανάλογα με την κατάστασή της. Αφορά απλές τηλεφωνικές συσκευές PSTN.</P>]]></description>
<ignoreProductLabelAndKeepSticky>No</ignoreProductLabelAndKeepSticky>
<phoneNumber>2431078247</phoneNumber>
<serviceCategory>TELEPHONY</serviceCategory>
<serviceType></serviceType>
<addressList>
<item>
<label>INSTALLATION ADDRESS</label>
<street>ΗΡ.ΑΛΒ.ΜΕΤΩΠΟΥ</street>
<streetNumber>20</streetNumber>
<postalCode>00000</postalCode>
<city>ΤΡΙΚΑΛΑ</city>
<province>ΤΡΙΚΑΛΩΝ</province>
<area>ΤΡΙΚΑΛΑ</area>
<poBox>No</poBox>
<sortOrderNo>0</sortOrderNo>
</item>
</addressList>
<hasUpsells>No</hasUpsells>
<visible>Yes</visible>
</item>
</children>
</item>
</children>
</item>
<item>
<idRef>W-125S1F-153P-1</idRef>
<parentIdRef>No</parentIdRef>
<eshopIdRef>No</eshopIdRef>
<subscriberId>No</subscriberId>
<psOfferReference>No</psOfferReference>
<title>11888 - All Occupations</title>
<description>No</description>
<ignoreProductLabelAndKeepSticky>Yes</ignoreProductLabelAndKeepSticky>
<phoneNumber>No</phoneNumber>
<serviceCategory>TELEPHONY</serviceCategory>
<serviceType></serviceType>
<addressList>No</addressList>
<hasUpsells>No</hasUpsells>
<visible>Yes</visible>
<children>
<item>
<idRef>W-125S1F-153S-1</idRef>
<parentIdRef>W-125S1F-153P-1</parentIdRef>
<eshopIdRef>No</eshopIdRef>
<subscriberId>No</subscriberId>
<psOfferReference>No</psOfferReference>
<title>Yellow Pages</title>
<description>No</description>
<ignoreProductLabelAndKeepSticky>Yes</ignoreProductLabelAndKeepSticky>
<phoneNumber>No</phoneNumber>
<serviceCategory>TELEPHONY</serviceCategory>
<serviceType></serviceType>
<addressList>No</addressList>
<hasUpsells>No</hasUpsells>
<visible>Yes</visible>
<children>
<item>
<idRef>W-125S1F-153T-1</idRef>
<parentIdRef>W-125S1F-153S-1</parentIdRef>
<eshopIdRef>No</eshopIdRef>
<subscriberId>No</subscriberId>
<psOfferReference>No</psOfferReference>
<title>Profession</title>
<description>No</description>
<ignoreProductLabelAndKeepSticky>Yes</ignoreProductLabelAndKeepSticky>
<phoneNumber>No</phoneNumber>
<serviceCategory>TELEPHONY</serviceCategory>
<serviceType></serviceType>
<addressList>No</addressList>
<hasUpsells>No</hasUpsells>
<visible>Yes</visible>
</item>
<item>
<idRef>W-125S1F-153U-1</idRef>
<parentIdRef>W-125S1F-153S-1</parentIdRef>
<eshopIdRef>No</eshopIdRef>
<subscriberId>No</subscriberId>
<psOfferReference>No</psOfferReference>
<title>Keywords</title>
<description>No</description>
<ignoreProductLabelAndKeepSticky>Yes</ignoreProductLabelAndKeepSticky>
<phoneNumber>No</phoneNumber>
<serviceCategory>TELEPHONY</serviceCategory>
<serviceType></serviceType>
<addressList>No</addressList>
<hasUpsells>No</hasUpsells>
<visible>Yes</visible>
</item>
</children>
</item>
</children>
</item>
</root>');
createCSV($xml);