无效的XML格式

时间:2014-04-11 05:17:23

标签: php xml

我在使用XML格式时遇到了一些问题。目前我正在通过订单在PHP中生成此XML。但是,当我提交它时,API告诉我,我的XML格式无效或格式不正确。

<?xml version="1.0" encoding="iso-8859-1"?>
<orders>
  <username>xxxxxxxxx</username>
  <password>xxxxxxx</password>
  <sandbox>1</sandbox>
  <order>
    <REFNUM>xxxxx</REFNUM>
    <SHIPSETTINGS>
      <ITEM>
        <VENDOR>ELD</VENDOR>
        <VSHIPNATIVE>M02</VSHIPNATIVE>
      </ITEM>
    </SHIPSETTINGS>
    <ORDER_DATE>xx/xx/xxxx</ORDER_DATE>
    <PRODUCTS>
      <item>
        <pnum>xxxxxxxxx</pnum>
        <qty>x</qty>
      </item>
    </PRODUCTS>
    <LASTNAME>xxxx</LASTNAME>
    <FIRSTNAME>xxxxx</FIRSTNAME>
    <ADDRESS1>xxxxxx</ADDRESS1>
    <ADDRESS2></ADDRESS2>
    <CITY>xxxxxx</CITY>
    <STATE>xxxxx</STATE>
    <ZIPCODE>xxxxx</ZIPCODE>
    <COUNTRY>xx</COUNTRY>
    <PHONE1>xxxxxxxxx</PHONE1>
    <EMAIL2>xxxxxxx</EMAIL2>
  </order>
</orders>

这是他们认为需要的XML格式。我不确定我做错了什么。谢谢你的帮助。抱歉,我忘了提及如果XML中有*,则表示它是必填字段。

<?xml version="1.0" encoding="iso-8859-1"?>

<orders>
   <username>*username</username>
   <password>*password</password>
   <sandbox>1</sandbox><-----------Add this parameter to test orders. Api will respond, but no order will be initiated!
   <order>
     <REFNUM>*dropshippers reference number</REFNUM>
     <SHIPSETTINGS>
        <ITEM>
          <VENDOR>MC</VENDOR>
          <VSHIPNATIVE>M02</VSHIPNATIVE>
        </ITEM>
      <ITEM>
          <VENDOR>ELD</VENDOR>
          <VSHIPNATIVE>UGR</VSHIPNATIVE>
        </ITEM>
          </SHIPSETTINGS>
          <ORDER_DATE>*5/16/08</ORDER_DATE>   
          <PRODUCTS>*
            <item>*
                <pnum>*ABC123</pnum>
                <qty>*1</qty>
            </item*>
            <item>
                <pnum>123ABC</pnum>
                <qty>3</qty>
            </item>
    </PRODUCTS>* 
    <LASTNAME>*Van Riper</LASTNAME> - Customer's shipping info.
    <FIRSTNAME>*Erik</FIRSTNAME> - Customer's shipping info.
    <COMPANY></COMPANY> - Customer's shipping info.  
    <ADDRESS1>*4720 Center Ave</ADDRESS1> - Customer's shipping info.
    <ADDRESS2>#515</ADDRESS2> - Customer's shipping info.  
    <CITY>*Wonder City</CITY> - Customer's shipping info.  
    <STATE>*NY</STATE> - Customer's shipping info.
    <ZIPCODE>*11109</ZIPCODE> - Customer's shipping info.
    <COUNTRY>*US</COUNTRY> - Customers 2 letter shipping country.
    <PHONE1>*(123) 555-1212</PHONE1> - Customer's Shipping phone # 1.
    <PHONE2>(555) 555-1212</PHONE2> - Customer's Shipping phone # 2.
    <EMAIL1>customer@location.com</EMAIL1> - Customer's billing email.
    <EMAIL2>*customer@location.com</EMAIL2> - Customer's shipping email. 
    </order>
</orders>

2 个答案:

答案 0 :(得分:1)

检查&lt; / item *&gt;,这应该是&lt; / item&gt;

答案 1 :(得分:0)

您发布的XML格式正确,因此不是问题所在。它们可能需要符合特定的DTD或模式,但除非您向我们展示,否则我们无法提供帮助。说明格式的样本XML是专有的,可能是非正式的符号,因此我们没有工具来检查其符合性。

基本上,您的帖子中没有任何信息可以帮助您。