Ebay api GetSellerList, Parsing response XML

前端 未结 1 1317
半阙折子戏
半阙折子戏 2021-01-27 07:33

I am using the ebay trading api to get a sellers stock which is currently listed. I am using the call GetSellerList.I am having trouble parsing the xml which I would then insert

相关标签:
1条回答
  • 2021-01-27 08:38

    This would be easier to answer if you posted the response XML (just the relevant portion) rather than the request.

    The code you have will only grab the first item - specifically this part:

    $dom->getElementsByTagName('Title')->item(0)->nodeValue
    

    Rather, you'll want to loop through all the Title elements and extract their nodeValue. This is a starting point:

    $dom = new DOMDocument();
    $dom->loadXML($response);
    $title_nodes = $dom->getElementsByTagName('Title');
    
    $titles = array();
    
    foreach ($title_nodes as $node) {
        $titles[] = $node->nodeValue;
    }
    
    0 讨论(0)
提交回复
热议问题