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!
出于某种原因,当脚本到达xml的“Brand”行时,一切都会停止,我无法找到原因。这里有没有人有类似的问题?如果有人可以帮我解决这个问题会很棒:)谢谢!
2 个解决方案
#1
1
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>
....
也许节点的值不是有效的xml格式,所以去告诉xml不要解析值...使用cdata标签
For reference you may want to read: [w3schools on xml CDATA]
供参考,您可能需要阅读:[x3 CDATA上的w3schools]
#2
0
Your XML syntax is fine and generates something similar as below.
您的XML语法很好,并生成类似于下面的内容。
1.01 Outdoor_outlet_seller
Product
true
124
Update
prod_sku1
A_GEN_TAX
2012-01-24T23:02:33+0000
prod_brand1
prod_descr
Sports & Outdoors
My guess is that something in the values returned by the $product functions that creates the problem. Try to echo the values alone to see if anything is unexpected
我的猜测是产生问题的$ product函数返回的值。尝试单独回显值,看看是否有任何意外
#1
1
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>
....
也许节点的值不是有效的xml格式,所以去告诉xml不要解析值...使用cdata标签
For reference you may want to read: [w3schools on xml CDATA]
供参考,您可能需要阅读:[x3 CDATA上的w3schools]
#2
0
Your XML syntax is fine and generates something similar as below.
您的XML语法很好,并生成类似于下面的内容。
1.01 Outdoor_outlet_seller
Product
true
124
Update
prod_sku1
A_GEN_TAX
2012-01-24T23:02:33+0000
prod_brand1
prod_descr
Sports & Outdoors
My guess is that something in the values returned by the $product functions that creates the problem. Try to echo the values alone to see if anything is unexpected
我的猜测是产生问题的$ product函数返回的值。尝试单独回显值,看看是否有任何意外