1 / 5

2003/08/05

2003/08/05. <?xml version="1.0" encoding="big5"?> <marketplace> <market> <name>guitar</name> <buyer> <filename>625105517buyer.xml</filename> </buyer> <seller> <filename>626214333seller.xml</filename> </seller> </market> </marketplace>.

jody
Télécharger la présentation

2003/08/05

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2003/08/05

  2. <?xml version="1.0" encoding="big5"?> <marketplace> <market> <name>guitar</name> <buyer> <filename>625105517buyer.xml</filename> </buyer> <seller> <filename>626214333seller.xml</filename> </seller> </market> </marketplace> • how to add a new filename here? • how to add a new filename here? 改進insert

  3. while(market.hasNext()){ • Element marketname=(Element)market.next(); • Iterator marketIterator=marketname.elementIterator("name"); • Element market_elem=(Element)marketIterator.next(); • Iterator buyerIterator=marketname.elementIterator("buyer"); • Element buyerfile=(Element)buyerIterator.next(); • if(market_elem.getText().equals(ProductName)){ • out.println("the same Product is =" +ProductName); • buyerfile.addElement("filename").addText(filename); • break; • }//end if • }// end while

  4. All.xml <?xml version="1.0" encoding="big5"?> <marketplace> <market> <name>pant</name> <buyer> <filename>722035buyer.xml</filename> <filename>721235010buyer.xml</filename> </buyer> <seller> <filename>626232920seller.xml</filename> <filename>722101050seller.xml</filename> <filename>722101029seller.xml</filename> </seller> </market> <market> <name>guitar</name> <buyer> <filename>625105517buyer.xml</filename> <filename>715134725buyer.xml</filename> </buyer> <seller> <filename>626214333seller.xml</filename> <filename>72323042seller.xml </filename> </seller> </market> </marketplace> <?xml version="1.0" encoding="big5"?> <marketplace> <market> <name>pant</name> <buyer> <filename>722035buyer.xml</filename> </buyer> <seller> <filename>626232920seller.xml</filename> </seller> </market> <market> <name>guitar</name> <buyer> <filename>625105517buyer.xml</filename> </buyer> <seller> <filename>626214333seller.xml</filename> </seller> </market> </marketplace>

  5. Facilitator.jsp while(market.hasNext()){ Element marketname=(Element)market.next(); Iterator marketIterator=marketname.elementIterator("name"); Element market_elem=(Element)marketIterator.next(); String market_dir=market_elem.getText(); //取得market的名稱 out.println("marketname = "+market_dir+" ; "); Iterator buyerIterator=marketname.elementIterator("buyer"); Element buyer_elem=(Element)buyerIterator.next(); Iterator buyerfileIterator=buyer_elem.elementIterator("filename"); //取得market/buyer/filename的名稱 Iterator sellerIterator=marketname.elementIterator("seller"); Element seller_elem=(Element)sellerIterator.next(); Iterator sellerfileIterator=seller_elem.elementIterator("filename"); while(buyerfileIterator.hasNext()&&sellerfileIterator.hasNext()){ //當buye跟seller皆有filename的元素時 Element buyerfile_elem=(Element)buyerfileIterator.next(); //進入while迴圈 String buyerfile=buyerfile_elem.getText(); Element sellerfile_elem=(Element)sellerfileIterator.next(); String sellerfile=sellerfile_elem.getText();

More Related