hungryfrank Posted November 16, 2016 Share Posted November 16, 2016 i am getting a syntax error in dreamweaver when i use this code because of blank space. $xml = simplexml_load_string($responseXml); foreach ($xml->Fees as $mes) { $name= $mes->fee->name ; $fee=$mes->fee->Fee currencyID="USD"; if ($name=='ListingFee')$listingfee=$mes->fee->Fee currencyID="USD"; } i am trying to get the listingfee from this <AddItemResponse xmlns="urn:ebay:apis:eBLBaseComponents"> <Timestamp>2016-02-16T18:52:41.543Z</Timestamp> <Ack>Success</Ack> <Version>967</Version> <Build>E967_CORE_BUNDLED_10639415_R1</Build> <ItemID>110043671232</ItemID> <StartTime>2016-02-16T18:52:41.027Z</StartTime> <EndTime>2016-02-23T18:52:41.027Z</EndTime> <Fees> <Fee> <Name>AuctionLengthFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>BoldFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>BuyItNowFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>CategoryFeaturedFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>FeaturedFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>GalleryPlusFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>FeaturedGalleryFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>FixedPriceDurationFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>GalleryFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>GiftIconFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>HighLightFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>InsertionFee</Name> <Fee currencyID="USD">0.25</Fee> </Fee> <Fee> <Name>InternationalInsertionFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>ListingDesignerFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>ListingFee</Name> <Fee currencyID="USD">0.25</Fee> </Fee> <Fee> <Name>PhotoDisplayFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>PhotoFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>ReserveFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>SchedulingFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>SubtitleFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>BorderFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>ProPackBundleFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>BasicUpgradePackBundleFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>ValuePackBundleFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>PrivateListingFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>ExtendedDurationFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>ProPackPlusBundleFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> <Fee> <Name>MotorsGermanySearchFee</Name> <Fee currencyID="USD">0.0</Fee> </Fee> </Fees> </AddItemResponse> Quote Link to comment https://forums.phpfreaks.com/topic/302548-how-do-i-parse-this-xml/ Share on other sites More sharing options...
requinix Posted November 17, 2016 Share Posted November 17, 2016 The name of the node is just "Fee". The rest of it is an attribute of the node. Quote Link to comment https://forums.phpfreaks.com/topic/302548-how-do-i-parse-this-xml/#findComment-1539384 Share on other sites More sharing options...
Barand Posted November 17, 2016 Share Posted November 17, 2016 Perhaps $listingFee = ''; foreach ($xml->Fees->Fee as $fee) { if ($fee->Name=='ListingFee') { $listingFee = sprintf('%0.2f%s', $fee->Fee, $fee->Fee['currencyID']); } } echo $listingFee; //--> 0.25USD Quote Link to comment https://forums.phpfreaks.com/topic/302548-how-do-i-parse-this-xml/#findComment-1539387 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.