I am simply trying to create this string
$post_string ='<?xml version="1.0" ?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amznenvelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>Outdoor_outlet_seller</MerchantIdentifier>
</Header>
<MessageType>Product</MessageType>
<PurgeAndReplace>true</PurgeAndReplace>
<Message>
<MessageID>' . rand(1,1000) . '</MessageID>
<OperationType>Update</OperationType>
<Product>
<SKU>'. $product->getSKU() . error_log("Got sku of product" . $product->getSKU()).'</SKU>
<ProductTaxCode>A_GEN_TAX</ProductTaxCode>
<LaunchDate>' . date('Y-m-d') . 'T' . date('H:i:sO') . '</LaunchDate>
<DescriptionData>
<Brand>'. $product->getBrand() . error_log($product->getBrand()) . '</Brand>
<Description>' . $product->getDescription() . '</Description>
<ItemType>Sports & Outdoors</ItemType>
</DescriptionData>
</Message>
</AmazonEnvelope>';
For some reason, everything just stops when the script reaches the “Brand” line of the xml and I cannot find out why. Has anyone here had a similar problem? It would be fantastic if someone could help me out with this 🙂 Thanks!
Maybe the node value its not in a valid xml format so go and tell xml not to parse the value … Use cdata tags
<Brand><![CDATA['. $product->getBrand() . error_log($product->getBrand()) . ']]></Brand>….For reference you may want to read: [w3schools on xml CDATA]