Xml Category on product feed - php

i want to post products to amazon to category of "SportsMemorabilia", using the mws product feed.
i looked over the documentation, it is hard to understand, i also download the xsd to see the xml structure
but still it dosent working.
for this xml is sent (it is only the category part, i also sending all other elements of the product xml..)
<ProductData>
<SportsMemorabilia>
<ProductType>SportsMemorabilia</ProductType>
</SportsMemorabilia>
</ProductData>
it give me this error
<Result>
<MessageID>0</MessageID>
<ResultCode>Error</ResultCode>
<ResultMessageCode>5000</ResultMessageCode>
<ResultDescription>XML Parsing Error at Line 104, Column 26: cvc-complex-type.2.4.b: The content of element 'SportsMemorabilia' is not complete. One of '{AuthenticatedBy}' is expected.</ResultDescription>
</Result>
please, write to me how the xml should look like in order it to work,
thank you.

As per the current version, this is the minimum XML that should pass the published XSD. It doesn't mean it'll work, as functionality built in the service may do additional validation.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<SportsMemorabilia>
<ProductType>SportsMemorabilia</ProductType>
<AuthenticatedBy>AuthenticatedBy1</AuthenticatedBy>
<ConditionProvidedBy>ConditionProvidedBy1</ConditionProvidedBy>
<ConditionRating>ConditionRating1</ConditionRating>
</SportsMemorabilia>
To access the services you need to have an account setup; you have to also fill in the other two elements, at least.
I would strongly suggest you to walk through the document posted here... At least the minimum above should get you over XSD validation errors.

Related

Make use of an index file for parsing a large XML file

I'm working on a Wikipedia XML Dump file (15GB), which is provided with an index text file.. looking like this :
1628813:431:Bille August
1628813:434:Blues
1628813:435:Bioéthique
1628813:436:Brive-la-Gaillarde
1628813:438:Burdigala
1628813:439:Bouliac
The XML file is basically in this format:
<page>
<title> </title>
<id> </id>
<revision>
<id> </id>
...
<text> </text>
</revision>
</page>
What I want is to get the Text tag content corresponding to specific page Titles.
How can I make use of the index file for quick parsing/searching to achieve this?
P.S: I already tried many solutions for quick parsing and nothing worked for my needs..
I'm working with PHP, I tried SAX parsing, which is quick but didn't allow me to handle the nodes the way I wanted, and tried combining XMLReader and SimpleXML, but it was too slow..

How to create a correct order test for Ingram micro integration?

I'm trying to create an order test for ingram micro and I have not achieved results.
This is the xml request to send:
<OrderRequest>
<Version>2.0</Version>
<TransactionHeader>
<SenderID>123456789</SenderID>
<ReceiverID>987654321</ReceiverID>
<CountryCode>MD</CountryCode>
<LoginID>ingram_login</LoginID>
<Password>ingram_password</Password>
<TransactionID>54321</TransactionID>
</TransactionHeader>
<OrderHeaderInformation>
<BillToSuffix />
<AddressingInformation>
<CustomerPO>TEST PO ONLY - DO NOT SHIP</CustomerPO>
<ShipToAttention>Mrs Jones</ShipToAttention>
<EndUserPO>EndUserPO_1</EndUserPO>
<ShipTo>
<Address>
<ShipToAddress1>Red House Company</ShipToAddress1>
<ShipToAddress2>1730 105TH ST</ShipToAddress2>
<ShipToAddress3/>
<ShipToCity>NEW RICHMOND</ShipToCity>
<ShipToProvince>WI</ShipToProvince>
<ShipToPostalCode>54017</ShipToPostalCode>
</Address>
</ShipTo>
</AddressingInformation>
<ProcessingOptions>
<CarrierCode>F2</CarrierCode>
<AutoRelease>H</AutoRelease>
<ThirdPartyFreightAccount/>
<KillOrderAfterLineError>N</KillOrderAfterLineError>
<ShipmentOptions>
<BackOrderFlag>Y</BackOrderFlag>
<SplitShipmentFlag>N</SplitShipmentFlag>
<SplitLine>N</SplitLine>
<ShipFromBranches>10</ShipFromBranches>
<DeliveryDate>20090901</DeliveryDate>
</ShipmentOptions>
</ProcessingOptions>
<DynamicMessage>
<MessageLines>Deliver to Mrs Jones</MessageLines>
</DynamicMessage>
</OrderHeaderInformation>
<OrderLineInformation>
<ProductLine>
<SKU>TSXML3</SKU>
<Quantity>1</Quantity>
<CustomerLineNumber/>
<ReservedInventory>
<ReserveCode>C</ReserveCode>
<ReserveSequence>01</ReserveSequence>
</ReservedInventory>
<CustomerPartNumber/>
<UPC/>
<ManufacturerPartNumber/>
<ShipFromBranchAtLine>10</ShipFromBranchAtLine>
</ProductLine>
<CommentLine>
<CommentText>TEST PO ONLY - DO NOT SHIP</CommentText>
</CommentLine>
</OrderLineInformation>
<ShowDetail>1</ShowDetail>
</OrderRequest>
ingram micro response:
<OrderResponse>
<Version>2.0</Version>
<TransactionHeader>
<SenderID>987654321</SenderID>
<ReceiverID>123456789</ReceiverID>
<ErrorStatus ErrorNumber="20196">
ERROR: One Productline can not have multiple parts in it when ShowDetail='2'
</ErrorStatus>
<DocumentID>{5535EC2F-DB51-4D35-B492-6425A0B9F62D}</DocumentID>
<TransactionID>54321</TransactionID>
<TimeStamp>2016-01-27T11:45:19</TimeStamp>
</TransactionHeader>
</OrderResponse>
I have been trying and researching about the response ErrorStatus and the Productline and I have not figured out a solution.
thanks in advance
Sorry, there is no ingram-micro tag
Just looking at the IM-XML documentation I could find, you have several apparent issues with the <ProductLine> element section of your example:
<ManufacturerPartNumber> Manufacturer Part Number
- Do not specify if <SKU> or <UPC> are included
<UPC> EAN/UPC Number
- Do not specify if <ManufacturerPartNumber> or <SKU> are included
<SKU> Ingram Micro product code Number
- Do not specify if <ManufacturerPartNumber> or <UPC> are included
Apparently you should only specify one of the above element's values, your example specifies values for SKU and UPC
<ReservedInventory> Contains reserved Inventory information.
- Unless required, do not specify.
It's not clear to me from my quick skim of the documentation when this would be required, but you specify a value for this element and I don't see any clear indication anywhere else in the example that would suggest why it would be required in your example case. So let's call this one a "maybe" issue.
<ShipFromBranchAtLine>
I couldn't find any reference to this element in the documentation, so it's probably invalid. The closest match to this element I could find was <ShipFromBranches>, which wouldn't belong in the <ProductLine> element.
<CustomerPartNumber>
Again, no reference to this that I could find in the documentation.
<RequestedPrice> Special Bid Price
Parent : <SpecialBid>
You have <RequestedPrice> as a direct child of ProductLine, when it should be inside of a <SpecialBid> element.
So with all of the above taken into account, I commented out the parts that seemed wrong (or potentially wrong, for our maybe) like so:
<ProductLine>
<SKU>NV9159</SKU>
<Quantity>1</Quantity>
<CustomerLineNumber/>
<!-- ResvervedInventory : Unless required, do not specify
<ReservedInventory>
<ReserveCode>C</ReserveCode>
<ReserveSequence>01</ReserveSequence>
</ReservedInventory>
-->
<!-- CustomerPartNumber element not defined in spec.
<CustomerPartNumber/>
-->
<!-- UPC : Do not specify if SKU included
<UPC>SP-RACKTRAY</UPC>
-->
<!-- ManufacturerPartNumber : Do not specify if SKU included
<ManufacturerPartNumber/>
-->
<!-- ShipFromBranchAtLine element not defined in spec.
<ShipFromBranchAtLine>10</ShipFromBranchAtLine>
-->
<!-- RequestedPrice : parent = SpecialBid
<RequestedPrice>163.36</RequestedPrice>
-->
</ProductLine>
If we just pulled those parts out (assuming none of them should be in there) and set them to empty elements, it might look something like:
<ProductLine>
<SKU>NV9159</SKU>
<Quantity>1</Quantity>
<CustomerLineNumber/>
</ProductLine>
Finally, in direct reference to the error you are getting back:
One Productline can not have multiple parts in it when ShowDetail='2'
I would assume that this is due directly to you setting a value for both <SKU> and <UPC>, which might confuse the system into thinking that you are trying to include "multiple parts" (eg two different part codes that might be for two different actual parts) when specifying (illegally) the value for those two elements.
But even if that weren't the case, it seems like the easiest thing to try to do, given the actual wording of that error, might be to try simply changing the ShowDetail element value from:
<ShowDetail>2</ShowDetail>
to
<ShowDetail>1</ShowDetail>
I would encourage fixing the other issues with the ProductLine element instead, but with the response error to go by alone, did you try changing ShowDetail to see if that made a difference?
I've was trying to send data setting the product line like this:
<ProductLine>
<SKU>TSXML3</SKU>
<Quantity>1</Quantity>
<CustomerLineNumber/>
<ReservedInventory>
<ReserveCode>C</ReserveCode>
<ReserveSequence>01</ReserveSequence>
</ReservedInventory>
</ProductLine>
I got this response:
<?xml version="1.0" encoding="ISO-8859-1"?>
<OrderResponse>
<Version>2.0</Version>
<TransactionHeader>
<SenderID>987654321</SenderID>
<ReceiverID>123456789</ReceiverID>
<ErrorStatus ErrorNumber="21340">Order Rejected</ErrorStatus>
<DocumentID>{584B79A8-E320-4183-A1BB-3DEE24CA673A}</DocumentID>
<TransactionID>54321</TransactionID>
<TimeStamp>2016-02-08T05:49:12</TimeStamp>
</TransactionHeader>
<OrderInfo>
<OrderNumbers>
<BranchOrderNumber></BranchOrderNumber>
<CustomerPO>TEST PO ONLY - DO NOT SHIP</CustomerPO>
<ShipToAttention>Mrs Jones</ShipToAttention>
<ThirdPartyFreightAccount></ThirdPartyFreightAccount>
<ShipToAddress1></ShipToAddress1>
<ShipToAddress2></ShipToAddress2>
<ShipToCity></ShipToCity>
<ShipToProvince></ShipToProvince>
<ShipToPostalCode></ShipToPostalCode>
<AddressErrorMessage AddressErrorType=" "></AddressErrorMessage>
<ContractNumber></ContractNumber>
<OrderSuffix Suffix="">
<LineInformation>
<ProductLine>
<LineError></LineError>
<SKU>TSXML3</SKU>
<UnitPrice>0.00</UnitPrice>
<IngramLineNumber></IngramLineNumber>
<CustomerLineNumber>000</CustomerLineNumber>
<ShipFromBranch>10</ShipFromBranch>
<OrderQuantity>1</OrderQuantity>
<AllocatedQuantity>0</AllocatedQuantity>
<BackOrderedQuantity>0</BackOrderedQuantity>
<BackOrderETADate></BackOrderETADate>
<PriceDerivedFlag></PriceDerivedFlag>
<ForeignCurrency></ForeignCurrency>
<FreightRate>0.00</FreightRate>
<TransitDays>0</TransitDays>
<LineBillToSuffix>000</LineBillToSuffix>
</ProductLine>
<CommentLine>
<CommentText>TEST PO ONLY - DO NOT SHIP</CommentText>
<CommentLineNumber></CommentLineNumber>
</CommentLine>
</LineInformation>
</OrderSuffix>
</OrderNumbers>
</OrderInfo>
</OrderResponse>
I hope this help you.

Re-ordering nodes in an xml via jquery ui drag and drop

I hope someone can help me here...
I am currently working on a small piece of code that will allow me to re-order nodes in an xml file via a jquery ui sortable interface.
Take the following xml file:
<Root>
<Page1>
<content>
This is content 1
</content>
</Page1>
<Page2>
<content>
This is content 2
</content>
</Page2>
<Page3>
<content>
This is content 3
</content>
</Page3>
</Root>
I have been able to use php to to build a drag and drop interface based on the number of nodes in the xml file. What I am trying to achieve is a way of saving the new order of the xml files when the data is passed from the sortable interface. From the jquery ui, I can get the ids required and I am able to pass that onto php. My main issue is how to manipulate the xml file to get the following result:
<Root>
<Page1>
<content>
This is content 3
</content>
</Page1>
<Page2>
<content>
This is content 1
</content>
</Page2>
<Page3>
<content>
This is content 2
</content>
</Page3>
</Root>
Hope this is making sense and I hope someone has an idea of how I can achieve this. Is it possible to do this with DOMDocument as I believe SimpleXML is not powerful enough to handle such a task.
My day would be made if a solution can be attained.
Thanks.

SimpleXML and PHP (XPATH)

Ok guys I'm using xml to store page information for a dynamic website. I need to figure out a way to take a variable(file name) and pull the related node and parse that information. so basically here's my XML structure...
<SITE>
<PAGE>
<FILENAME>sub.php</FILENAME>
<DESCRIPTION>this is an example sub page</DESCRIPTION>
<TITLE>NOH Sub page</TITLE>
<PARENTS>
<PARENT>What is NOH</PARENT>
</PARENTS>
</PAGE>
<PAGE>
<FILENAME>about.php</FILENAME>
<DESCRIPTION>description description description </DESCRIPTION>
<TITLE>About Us</TITLE>
<PARENTS>
<PARENT>Company</PARENT>
<PARENT>People</PARENT>
</PARENTS>
</PAGE>
</SITE>
Is there a way to use SimpleXML and PHP to take a variable say.. 'sub.php' and say I want the node where filename = 'sub.php', and then be able to parse that node(page) for needed info. Thanks!
Update, where I'm confused is...
i have this function
function getPage($pagePath){
$file = "includes/sitestructure.xml";
$xml = simplexml_load_file($file);
return print_r($xml-xpath(PAGE/FILENAME));
}
but my xpath doesn't work, and I'm not sure how to logically get the info I need.. I know how to normally parse XML with PHP but not how to specify a specific node by comparing it to a variable then parse it.
$xml-xpath(PAGE/FILENAME)
This is broken in several ways, but this is an XPath question not a PHP syntax one.
You want to get the PAGE element(s) which contain a FILENAME of your chosen file name. To do that in XPath, a predicate can be used.
PAGE[FILENAME="sub.php"]
In your PHP code that might look like
$pages = $xml->xpath('PAGE[FILENAME="sub.php"]');
$first_page = $pages[0];
echo $first_page->TITLE; // NOH Sub page
The important point here is the use of the predicate to filter the result to only the page element(s) that you want.
http://www.w3.org/TR/xpath/#predicates

Displaying an XML file with XSL within an existing webpage

I'm trying to get an html page to display an XML file formatted with an XSL stylesheet. Whatever examples I see are either displaying it in a new page, with the XSL stylesheet taking care of the tags, but no examples where I can clearly see it being displayed as part of an existing webpage...
I'm using a PHP script to generate the HTML. And the XML data is being generated by another PHP function (not under my control). The XSL file is uploaded on the server and stored at: /xsl/1234567890.xsl
Here's what the php outputs:
<html>
...
<body>
...
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/xsl/1234567890.xsl"?>
...
<xml tags>
...
What am I doing wrong?
Two ways to transform the XML:
1 browser
Most browsers implement XSLT processors. You could use:
<iframe src="xml-source.xml"/>
The users will have to make three requests (page, xml, xsl) and unless you want inline scrollbars you'll need some Javascript to resize the iframe.
2 server
You can run a XSLT processor on the server side and return the transformed XML. There are many ways to do this, here is one in PHP. With caching you shouldn't run into any performance problems and also support browsers without internal XSLT processors (e.g. mobile devices).

Categories