這是我正在使用的XML文件的一個小例子。我想提取賣家評級大於150的拍賣數量。有誰知道我如何去做這件事?使用R從xml文件中提取多個值
<root>
<listing>
<seller_info>
<seller_name>seller12</seller_name>
<seller_rating>100</seller_rating>
</seller_info>
<payment_types>
Visa
</payment_types>
<shipping_info>
Buyer pays shipping charges.
</shipping_info>
<buyer_protection_info></buyer_protection_info>
<auction_info>
<current_bid>$820.00</current_bid>
<time_left>4 days, 18 hours +</time_left>
<high_bidder>
<bidder_name>[email protected]</bidder_name>
<bidder_rating>-2</bidder_rating>
</high_bidder>
<num_items>1</num_items>
<num_bids>12</num_bids>
<started_at>$1.00</started_at>
<bid_increment></bid_increment>
<notes></notes>
</auction_info>
</listing>
<listing>
<seller_info>
<seller_name>seller50</seller_name>
<seller_rating>200</seller_rating>
</seller_info>
<payment_types>
Visa
</payment_types>
<shipping_info>
Buyer pays shipping charges.
</shipping_info>
<buyer_protection_info></buyer_protection_info>
<auction_info>
<current_bid>$920.00</current_bid>
<time_left>4 days, 17 hours +</time_left>
<high_bidder>
<bidder_name>[email protected]</bidder_name>
<bidder_rating>-2</bidder_rating>
</high_bidder>
<num_items>1</num_items>
<num_bids>5</num_bids>
<started_at>$1.00</started_at>
<bid_increment></bid_increment>
<notes></notes>
</auction_info>
</listing>
<root>
到目前爲止,我已經使用解析這個xmlTreeParse
數據和使用xpathSapply
doc <- xmlTreeParse("ebay.xml", useInternalNodes = TRUE)
log <- xpathSApply(doc, '//*/seller_rating')
那麼,什麼是你試圖代碼的問題?什麼是期望的結果? – Parfait
@Parfait問題是我提取賣家評級的所有拍賣,而不僅僅是賣家評級大於150的拍賣。我只想輸出賣家評級> 150的拍賣數量 – Amanda