XML read Multi-Layer Nodes

Source: Internet
Author: User
  • Xmldocument xml =NewXmldocument ();
  • XML. Load ("D: \ XML \ sellgame. xml")
  • Xmlnamespacemanager nsmgr =
  • NewXmlnamespacemanager (NewXmldocument (). nametable );
  •  // Create an XML namespace manager object 
  • Nsmgr. addnamespace ("V","Www-shop-game");
  • // Add a namespace, C # Read XML for XML operations
  • StringPrice = xml. selectsinglenode (
  • "V: Games/V: Game [@ name = 'civilization 3']/price", Nsmgr). innertext;
  • // Obtain the corresponding node Value
 
* ***** ReadAll civilizations 3*************************************** **************************************** ***


  • Xmlnamespacemanager nsmgr =
  • NewXmlnamespacemanager (
  • NewXmldocument (). nametable );
  • // Create an XML namespace manager object 
  • Nsmgr. addnamespace ("V","Www-shop-game");
  •  // Add a namespace, C # Read XML for XML operations
  • Xmlnodelist nodelist = xml. selectnodes (
  • "V: Games/V: Game [@ name = 'civilization 3']/price", Nsmgr );
  •  // Obtain the corresponding node Array
 
****************************** **************************************** ************
 



  1. <? XML version ="1.0"Encoding ="UTF-8"? >
  2. <V: Games xmlns: V ="Www-shop-game">
  3. <V: Game name ="Civilization 3"Type ="Standard">
  4. <Price> 100 </price>
  5. </Game> // C # Read XML for XML operations
  6. <V: Game name ="Civilization 3"Type ="Classic">
  7. <Price> 500 </price>
  8. </Game>
  9. <V: Game name ="Age of Empire">
  10. <Price> 200 </price>
  11. </Game>
  12. </Games>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.