i am trying to read the response generated from ebay api.Response is
if i am reading the value of
Ack
tag it is fine. but if i am reading the value of
ItemID
it is givin null;
<?xml version="1.0" encoding="UTF-8"?>
<AddItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2015-09-02T12:18:20.267Z</Timestamp>
<Ack>Warning</Ack>
<Errors>
<ShortMessage>Listing may violate the Duplicate Listing policy.</ShortMessage>
<LongMessage>This listing may be identical to test5 (110167922580). Under our duplicate listing policy, it may not be shown to buyers. When the identical listing receives a bid, this listing will be shown to buyers. If the items you want to sell are not identical, revise your listings to make the differences more obvious.</LongMessage>
<ErrorCode>21917239</ErrorCode>
<SeverityCode>Warning</SeverityCode>
<ErrorParameters ParamID="0">
<Value>test5</Value>
</ErrorParameters>
<ErrorParameters ParamID="1">
<Value>110167922580</Value>
</ErrorParameters>
<ErrorClassification>RequestError</ErrorClassification>
</Errors>
<Version>931</Version>
<Build>E931_UNI_API5_17617533_R1</Build>
<ItemID>110167925316</ItemID>
<StartTime>2015-09-02T12:18:19.783Z</StartTime>
<EndTime>2015-09-09T12:18:19.783Z</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>
what i have written to read the xml is :
public String readXMLResponse(XmlStreamReader reader, String sxmltag)
{
string retValue;
while(reader.hasNext()) {
if (reader.getEventType() == XmlTag.START_ELEMENT) {
if (reader.getLocalName()== sxmltag) {
reader.next();
if (reader.getEventType() == XmlTag.characters) {
retValue = reader.getText();
}
}
}
reader.next();
}
return retValue;
}
and trying to find the value by :--
result = readXMLResponse(reader,'Ack');
result2 = readXMLResponse(reader,'ItemID');
result2 is null however response xml have value within this tag. please help.
Update
public String readXMLResponse(XmlStreamReader reader, String sxmltag)
{
string retValue;
while(reader.hasNext()) {
if (reader.getEventType() == XmlTag.START_ELEMENT) {
if (reader.getLocalName()== sxmltag) {
reader.next();
if (reader.getEventType() == XmlTag.characters) {
retValue = reader.getText();
system.debug('within readresponse1'+retValue);
}
}
}
reader.next();
}
return retValue;
}
Thanks in advance..
<Fees>
, instead I see what appears to be an extra<Fee>
which could be the source of your problem.