Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to read the specific tag [modified]

how to read the specific tag [modified]

Scheduled Pinned Locked Moved C#
questionxmltutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    YiXiang_89
    wrote on last edited by
    #1

    hi all This is to read the tag line by line. using System.Xml; ... ... ... XmlTextReader reader = new XmlTextReader ("reader.xml"); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. Console.Write("<" + reader.Name); Console.WriteLine(">"); break; case XmlNodeType.Text: //Display the text in each element. Console.WriteLine (reader.Value); break; case XmlNodeType.EndElement: //Display the end of the element. Console.Write("</" + reader.Name); Console.WriteLine(">"); break; } } Console.ReadLine(); How do i read the specific tag if i just want to read all the tag that have this < big > tag? thank you

    modified on Monday, April 13, 2009 3:36 AM

    J 1 Reply Last reply
    0
    • Y YiXiang_89

      hi all This is to read the tag line by line. using System.Xml; ... ... ... XmlTextReader reader = new XmlTextReader ("reader.xml"); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. Console.Write("<" + reader.Name); Console.WriteLine(">"); break; case XmlNodeType.Text: //Display the text in each element. Console.WriteLine (reader.Value); break; case XmlNodeType.EndElement: //Display the end of the element. Console.Write("</" + reader.Name); Console.WriteLine(">"); break; } } Console.ReadLine(); How do i read the specific tag if i just want to read all the tag that have this < big > tag? thank you

      modified on Monday, April 13, 2009 3:36 AM

      J Offline
      J Offline
      Jimmanuel
      wrote on last edited by
      #2

      use an XmlDocument[^] and the SelectNodes[^] method to search for specific nodes. This[^] article has a nice cheat sheet of the XPath syntax for searching for nodes.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups