谁能告诉我这格式不正确 XML?
Can anyone please tell me how this is not well formed XML?
上下文:我正在尝试向 ShipAccept api 发送 UPS 测试请求。我收到一条错误消息,告诉我 xml 文档格式不正确。我发送的实际请求包含所有必需的信息,这只是相同的格式。
<AccessRequest xml:lang="en-US">
<AccessLicenseNumber>Your_License</AccessLicenseNumber>
<UserId>Your_ID</UserId>
<Password>Your_Password</Password>
</AccessRequest>
</?xml version="1.0"?>
<ShipmentConfirmRequest xml:lang="en-US">
<Request>
<TransactionReference>
<CustomerContext>Customer Comment</CustomerContext>
</TransactionReference>
<RequestAction>ShipConfirm</RequestAction>
<RequestOption>validate</RequestOption>
</Request>
<LabelSpecification>
<LabelPrintMethod>
<Code>GIF</Code>
<Description>gif file</Description>
</LabelPrintMethod>
<HTTPUserAgent>Mozilla/4.5</HTTPUserAgent>
<LabelImageFormat>
<Code>GIF</Code>
<Description>gif</Description>
</LabelImageFormat>
</LabelSpecification>
<Shipment>
<RateInformation>
<NegotiatedRatesIndicator/>
</RateInformation>
<Description/>
<Shipper>
<Name>Shipper Name</Name>
<PhoneNumber>1234567890</PhoneNumber>
<ShipperNumber>Ship Number</ShipperNumber>
<TaxIdentificationNumber>1234567877</TaxIdentificationNumber>
<Address>
<AddressLine1>Address Line</AddressLine1>
<City>City</City>
<StateProvinceCode>MD</StateProvinceCode>
<PostalCode>21093</PostalCode>
<PostcodeExtendedLow></PostcodeExtendedLow>
<CountryCode>US</CountryCode>
</Address>
</Shipper>
<ShipTo>
<CompanyName>Ship To Company Name</CompanyName>
<AttentionName>Ship To Attn Name</AttentionName>
<PhoneNumber>97225377171</PhoneNumber>
<Address>
<AddressLine1>Address Line</AddressLine1>
<City>City</City>
<StateProvinceCode>FL</StateProvinceCode>
<PostalCode>32960</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</ShipTo>
<ShipFrom>
<CompanyName>Ship From Company Name</CompanyName>
<AttentionName>Ship From Attn Name</AttentionName>
<PhoneNumber>1234567890</PhoneNumber>
<TaxIdentificationNumber>1234567877</TaxIdentificationNumber>
<Address>
<AddressLine1>Address Line</AddressLine1>
<City>City</City>
<StateProvinceCode>MD</StateProvinceCode>
<PostalCode>21093</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</ShipFrom>
<PaymentInformation>
<Prepaid>
<BillShipper>
<AccountNumber>Ship Number</AccountNumber>
</BillShipper>
</Prepaid>
</PaymentInformation>
<Service>
<Code>02</Code>
<Description>2nd Day Air</Description>
</Service>
<Package>
<PackagingType>
<Code>02</Code>
<Description>Customer Supplied</Description>
</PackagingType>
<Description>Package Description</Description>
<ReferenceNumber>
<Code>00</Code>
<Value>Package</Value>
</ReferenceNumber>
<PackageWeight>
<UnitOfMeasurement/>
<Weight>60.0</Weight>
</PackageWeight>
<LargePackageIndicator/>
<AdditionalHandling>0</AdditionalHandling>
</Package>
</Shipment>
</ShipmentConfirmRequest>
此外,缩进对 xml 重要吗?我的缩进错误是否是文档格式不正确的原因?我对 xml 没有任何经验,但不幸的是,UPS api 接受大多数东西作为 json 除了运输部件。非常感谢您提前为我提供的任何帮助!
编辑:所提供的代码是他们自己的正确请求示例,所以我感到非常困惑。
一个XML文档只能有一个根。你这里有 two XML 文件,在第二个文件的声明中有拼写错误。
</AccessRequest> <-- end of the root element of the 1st doc
</?xml version="1.0"?> <-- Probably an XML declaration of the 2nd doc.
Shouldn't have the slash.
<ShipmentConfirmRequest xml:lang="en-US">
上下文:我正在尝试向 ShipAccept api 发送 UPS 测试请求。我收到一条错误消息,告诉我 xml 文档格式不正确。我发送的实际请求包含所有必需的信息,这只是相同的格式。
<AccessRequest xml:lang="en-US">
<AccessLicenseNumber>Your_License</AccessLicenseNumber>
<UserId>Your_ID</UserId>
<Password>Your_Password</Password>
</AccessRequest>
</?xml version="1.0"?>
<ShipmentConfirmRequest xml:lang="en-US">
<Request>
<TransactionReference>
<CustomerContext>Customer Comment</CustomerContext>
</TransactionReference>
<RequestAction>ShipConfirm</RequestAction>
<RequestOption>validate</RequestOption>
</Request>
<LabelSpecification>
<LabelPrintMethod>
<Code>GIF</Code>
<Description>gif file</Description>
</LabelPrintMethod>
<HTTPUserAgent>Mozilla/4.5</HTTPUserAgent>
<LabelImageFormat>
<Code>GIF</Code>
<Description>gif</Description>
</LabelImageFormat>
</LabelSpecification>
<Shipment>
<RateInformation>
<NegotiatedRatesIndicator/>
</RateInformation>
<Description/>
<Shipper>
<Name>Shipper Name</Name>
<PhoneNumber>1234567890</PhoneNumber>
<ShipperNumber>Ship Number</ShipperNumber>
<TaxIdentificationNumber>1234567877</TaxIdentificationNumber>
<Address>
<AddressLine1>Address Line</AddressLine1>
<City>City</City>
<StateProvinceCode>MD</StateProvinceCode>
<PostalCode>21093</PostalCode>
<PostcodeExtendedLow></PostcodeExtendedLow>
<CountryCode>US</CountryCode>
</Address>
</Shipper>
<ShipTo>
<CompanyName>Ship To Company Name</CompanyName>
<AttentionName>Ship To Attn Name</AttentionName>
<PhoneNumber>97225377171</PhoneNumber>
<Address>
<AddressLine1>Address Line</AddressLine1>
<City>City</City>
<StateProvinceCode>FL</StateProvinceCode>
<PostalCode>32960</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</ShipTo>
<ShipFrom>
<CompanyName>Ship From Company Name</CompanyName>
<AttentionName>Ship From Attn Name</AttentionName>
<PhoneNumber>1234567890</PhoneNumber>
<TaxIdentificationNumber>1234567877</TaxIdentificationNumber>
<Address>
<AddressLine1>Address Line</AddressLine1>
<City>City</City>
<StateProvinceCode>MD</StateProvinceCode>
<PostalCode>21093</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</ShipFrom>
<PaymentInformation>
<Prepaid>
<BillShipper>
<AccountNumber>Ship Number</AccountNumber>
</BillShipper>
</Prepaid>
</PaymentInformation>
<Service>
<Code>02</Code>
<Description>2nd Day Air</Description>
</Service>
<Package>
<PackagingType>
<Code>02</Code>
<Description>Customer Supplied</Description>
</PackagingType>
<Description>Package Description</Description>
<ReferenceNumber>
<Code>00</Code>
<Value>Package</Value>
</ReferenceNumber>
<PackageWeight>
<UnitOfMeasurement/>
<Weight>60.0</Weight>
</PackageWeight>
<LargePackageIndicator/>
<AdditionalHandling>0</AdditionalHandling>
</Package>
</Shipment>
</ShipmentConfirmRequest>
此外,缩进对 xml 重要吗?我的缩进错误是否是文档格式不正确的原因?我对 xml 没有任何经验,但不幸的是,UPS api 接受大多数东西作为 json 除了运输部件。非常感谢您提前为我提供的任何帮助!
编辑:所提供的代码是他们自己的正确请求示例,所以我感到非常困惑。
一个XML文档只能有一个根。你这里有 two XML 文件,在第二个文件的声明中有拼写错误。
</AccessRequest> <-- end of the root element of the 1st doc
</?xml version="1.0"?> <-- Probably an XML declaration of the 2nd doc.
Shouldn't have the slash.
<ShipmentConfirmRequest xml:lang="en-US">