Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

XML Attribute

Last post 01-05-2008 10:48 AM by Mulish Mehdi. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 01-05-2008 3:56 AM

    • visal_cam
    • Not Ranked
    • Joined on 09-25-2007
    • Cambodia
    • New Member
    • Points 20

    XML Attribute

    I got this xml file:

    <record>

    <employee id="01" lname="aa" fname="bb" sex="m"/>

    <employee id="02" lname="cc" fname="dd" sex="f"/>

    <employee id="03" lname="ee" fname="ff" sex="m"/>

    </record>

    output should be:

    employee id        name             sex 

                   01       aa bb              m

                   02       cc dd               f

                   03       ee ff                m

     

    Please someone help me to write code with asp.net (C#) to read xml file above.

    Urgent!!!!

    Best Regard!

    • Post Points: 10
  • 01-05-2008 10:48 AM In reply to

    Re: XML Attribute

    Hi there,

    using System;
    using System.Xml;
    using System.Windows.Forms;

    namespace WindowsApplication2
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
    XmlReader xreader = XmlReader.Create("C:\\Users.xml");
    while (xreader.Read())
    {
    if (xreader.NodeType == XmlNodeType.Element && xreader.Name == "employee")
    {
    textBox1.Text += string.Format("{0}-{1}-{2}-{3}\r\n", xreader.GetAttribute("id"), xreader.GetAttribute("lname"), xreader.GetAttribute("fname"), xreader.GetAttribute("sex"));
    }
    }
    xreader.Close();
    }

    }
    }
    Regards,
    Mehdi Golchin
    • Post Points: 5
Page 1 of 1 (2 items)