letoii Posted December 10, 2010 Share Posted December 10, 2010 I am constructing an XML file with PHP. I read information from a template XML file and then add elements and save it. The line breaks from the template are preserved in the saved file, but all the new elements are on one line. Is there a way to break them up so it is easier to read the file? Here is the original template: <InternationalShippingServiceOption> <ShippingService> token </ShippingService> <ShippingServiceAdditionalCost currencyID="CurrencyCodeType"> AmountType (double) </ShippingServiceAdditionalCost> <ShippingServiceCost currencyID="CurrencyCodeType"> AmountType (double) </ShippingServiceCost> <ShippingServicePriority> int </ShippingServicePriority> </InternationalShippingServiceOption> Here is the saved information (all the ShipToLocation elements on one line): <InternationalShippingServiceOption> <ShippingService>StandardInternational</ShippingService> <ShippingServiceAdditionalCost currencyID="CurrencyCodeType">26.994</ShippingServiceAdditionalCost> <ShippingServiceCost currencyID="CurrencyCodeType">44.99</ShippingServiceCost> <ShippingServicePriority>2</ShippingServicePriority> <ShipToLocation>BE</ShipToLocation><ShipToLocation>FR</ShipToLocation><ShipToLocation>IE</ShipToLocation><ShipToLocation>LU</ShipToLocation><ShipToLocation>MC</ShipToLocation><ShipToLocation>NL</ShipToLocation><ShipToLocation>GB</ShipToLocation><ShipToLocation>DE</ShipToLocation><ShipToLocation>IT</ShipToLocation></InternationalShippingServiceOption> I am using the $doc->formatOutput = true; option. Link to comment https://forums.phpfreaks.com/topic/221175-how-to-add-line-breaks-to-php-generated-xml-files/ Share on other sites More sharing options...
requinix Posted December 10, 2010 Share Posted December 10, 2010 How are you creating the new XML? Link to comment https://forums.phpfreaks.com/topic/221175-how-to-add-line-breaks-to-php-generated-xml-files/#findComment-1145182 Share on other sites More sharing options...
letoii Posted December 10, 2010 Author Share Posted December 10, 2010 createElement then appendChild $ShipToLocation = $doc->createElement('ShipToLocation',$countryRow["ebay_code"]); $doc->documentElement->appendChild($ShipToLocation); Link to comment https://forums.phpfreaks.com/topic/221175-how-to-add-line-breaks-to-php-generated-xml-files/#findComment-1145183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.