Does anyone help me get another child of the following XML:
& Lt; ? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; GetItemResponse xmlns = "Kalash: eBay: APIs: EBLbase Content" & gt; & Lt; Timestamp & gt; 2013-03-27T03: 39: 01.575Z & lt; / Timestamp & gt; & Lt; Ack & gt; Success & lt; / Ack & gt; & Lt; Version & gt; 815 & lt; / Edition & gt; & Lt; Build & gt; E815_CORE_API_15855340_R1 & lt; / Build & gt; & Lt; Items & gt; & Lt; ApplicationData & gt; 881030. B.0000 & lt; / ApplicationData & gt; & Lt; Automatic payment & gt; False & lt; / Automatic payments & gt; & Lt; BuyerProtection & gt; ItemEligible & lt; / BuyerProtection & gt; & Lt; BuyItNowPrice currencyID = "USD" & gt; 0.0 & lt; / BuyItNowPrice & gt; & Lt; Country & gt; America & lt; / Country & gt; & Lt; Currency & gt; Dollar & lt; / Currency & gt; & Lt; Gifticon & gt; 0 & lt; / Gifticon & gt; & Lt; HitCounter & gt; RetroStyle & lt; / HitCounter & gt; & Lt; ItemID & gt; & Lt; / ItemID & gt; & Lt; ListingDetails & gt; & Lt; Adult & gt; False & lt; / Adlt & gt; & Lt; BindingAuction & gt; False & lt; / BindingAuction & gt; & Lt; CheckoutEnabled & gt; True & lt; / CheckoutEnabled & gt; & Lt; ConvertibuetinoPrice Currency ID = "USD" & gt; 0.0 & lt; / ConvertedBuyItNowPrice & gt; & Lt; ShippingServiceOptions & gt; & Lt; ShippingService & gt; UPSGround & lt; / ShippingService & gt; & Lt; Shipping servicecast currencyID = "USD" & gt; 9.99 & lt; / ShippingServiceCost & gt; & Lt; / ShippingServiceOptions & gt; & Lt; InternationalShippingServiceOption & gt; & Lt; ShippingService & gt; StandardInternational & lt; / ShippingService & gt; & Lt; Shipping ServiceCast Currency ID = "USD" & gt; 39.99 & lt; / ShippingServiceCost & gt; & Lt; / InternationalShippingServiceOption & gt; & Lt; Items & gt; I am using one to see the cycle through all the items ($ items as $ items). I need to get the service from shipping service and shipping.
I want to do the following but this does not work:
// $ $ item for shipping- item-> GetElementsByTagName ('ShippingServiceCost') - & gt; Items (0) - & gt; NodeValue; // $ items for international services- & gt; GetElementsByTagName ('shipping servicecast') - & gt; Item (1) - & gt; Nodeville; Edit
Edit
Because you have posted the full XML Php Xml traversing will look like this:
$ xml = simplexml_load_string ($ response); Foreign currency ($ xml - gt; item-> listing as a $ child) {foreach ($ child- & gt; children () as the $ option) {if (isset ($ option-> ; Shipping service service)) {echo $ option- & gt; GetName () ":". $ Option- & gt; Shipping ServiceCast "& lt; br & gt;"; The XML you posted contains errors, in the future please validate it before posting so that we do not need to fix the errors.)
If you have PHP 5 + So you can use Simplex to parse your XML. In addition, you have to close your "item" XML tag.
Then the code is created:
& lt ;? Php $ xml = simplexml_load_file ("test.xml"); Foreign ($ xml- & gt; children () $ as child) {echo $ child-> GetName () ":". $ Child-> Shipping ServicesCast "& lt; br & gt;"; }? & Gt; XML:
& lt; Items & gt; & Lt; ShippingServiceOptions & gt; & Lt; ShippingService & gt; UPSGround & lt; / ShippingService & gt; & Lt; Shipping servicecast currencyID = "USD" & gt; 9.99 & lt; / ShippingServiceCost & gt; & Lt; / ShippingServiceOptions & gt; & Lt; InternationalShippingServiceOption & gt; & Lt; ShippingService & gt; StandardInternational & lt; / ShippingService & gt; & Lt; Shipping ServiceCast Currency ID = "USD" & gt; 39.99 & lt; / ShippingServiceCost & gt; & Lt; / InternationalShippingServiceOption & gt; & Lt; / Item & gt; Output:
Shipping Services Option: 9.99 International Shipping Service: 39.99
No comments:
Post a Comment