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. Simple XML Exercise plz Help!

Simple XML Exercise plz Help!

Scheduled Pinned Locked Moved C#
xmlhelp
4 Posts 3 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.
  • R Offline
    R Offline
    rockxuyenmandem
    wrote on last edited by
    #1

    Part 1: Use XML text writer class to create the following XML file: 1233 Hard disk 12 200 1235 Monitor 10 300 Part 2: Use the XMLTextReader to read the file created in the Part 1 and display data as shown below: Hardisk 12 200 Monitor 10 300 I already done Part 1 but i can't done Part 2, I am newbie, Plz Help. Thanksssssssssssss -- modified at 2:49 Tuesday 25th April, 2006

    S A 2 Replies Last reply
    0
    • R rockxuyenmandem

      Part 1: Use XML text writer class to create the following XML file: 1233 Hard disk 12 200 1235 Monitor 10 300 Part 2: Use the XMLTextReader to read the file created in the Part 1 and display data as shown below: Hardisk 12 200 Monitor 10 300 I already done Part 1 but i can't done Part 2, I am newbie, Plz Help. Thanksssssssssssss -- modified at 2:49 Tuesday 25th April, 2006

      S Offline
      S Offline
      sathish s
      wrote on last edited by
      #2

      Easiest way is to Load this xml into a dataset and read this from the dataset

      DataSet ds=new DataSet();
      ds.ReadXml("Filepath");)

      R 1 Reply Last reply
      0
      • S sathish s

        Easiest way is to Load this xml into a dataset and read this from the dataset

        DataSet ds=new DataSet();
        ds.ReadXml("Filepath");)

        R Offline
        R Offline
        rockxuyenmandem
        wrote on last edited by
        #3

        Ohh, thanks alots :) I tried so hard and got so far

        1 Reply Last reply
        0
        • R rockxuyenmandem

          Part 1: Use XML text writer class to create the following XML file: 1233 Hard disk 12 200 1235 Monitor 10 300 Part 2: Use the XMLTextReader to read the file created in the Part 1 and display data as shown below: Hardisk 12 200 Monitor 10 300 I already done Part 1 but i can't done Part 2, I am newbie, Plz Help. Thanksssssssssssss -- modified at 2:49 Tuesday 25th April, 2006

          A Offline
          A Offline
          alwz_nikhil
          wrote on last edited by
          #4

          USE THIS CODE U WILL GET UR REQUIRED FORMAT using System; using System.Xml; namespace ConsoleApplication1 { class Class1 { static void Main(string[] args) { XmlTextReader reader =new XmlTextReader("path of file"); string id=null; string productname=null; string quantity=null; string unitprice=null; while(reader.Read()) { switch(reader.NodeType.ToString()) { case "Element": switch(reader.Name.ToString()) { case "id" : id = reader.ReadElementString().ToString(); break; case "productname": productname = reader.ReadElementString().ToString(); break; case "quantity": quantity = reader.ReadElementString().ToString(); break; case "unitprice": unitprice = reader.ReadElementString().ToString(); break; } break; case "EndElement": if( reader.Name.ToString() == "item") { Console.WriteLine(id +" "+ productname +" "+ quantity +" "+ unitprice); id=null; productname=null; quantity=null; unitprice=null; } break; } }//while } } }

          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