StewSupport
asked on
write to xml asp.net
i want to delete content of existing xml file and then write new data to it. how do i do that in vb.net asp.net thanks.
ASKER
and then read this out so you can create a listbox out of this.
<class name ="English" id= "class1">
<studentinfo id="1">
<studentname>Anderson</stu dentname>
<studentid>1111</studentid >
</studentinfo>
</class>
i will have multiple class and multiple studentinfo. can you guys help please. thanks.
<class name ="English" id= "class1">
<studentinfo id="1">
<studentname>Anderson</stu
<studentid>1111</studentid
</studentinfo>
</class>
i will have multiple class and multiple studentinfo. can you guys help please. thanks.
In which format you want to display this. Or you just want to read this.
ASKER
well i just want to read the xml in the format i gave abve and then put that into a select list
like this
<select ....>
<option group=English>
<option value=studentid>Student name</option>
</select>
like this
<select ....>
<option group=English>
<option value=studentid>Student name</option>
</select>
ASKER
sorry i want to read and write(create) xml file
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
this is the format i have
<?xml version="1.0" encoding="utf-8" ?>
<catalog>
<optgroup label="Bakery">
<option value="111">Chicken</optio n>
</optgroup>
<optgroup label="BBQ">
<option value="222">Fried</option>
</optgroup>
</catalog>
how do i read it so that i would have label in the select list and then value and text in item?
i have this and dont know where to go from there.
For Each productnode In nodelist
If productnode.Attributes.Cou nt > 0 Then
For Each productsubnode In productnode.ChildNodes
'add to child list box
ListBox_Section1.Items.Add (New ListItem(productsubnode.Na me.ToStrin g, productsubnode.Value.ToStr ing))
Next
End If
Next
<?xml version="1.0" encoding="utf-8" ?>
<catalog>
<optgroup label="Bakery">
<option value="111">Chicken</optio
</optgroup>
<optgroup label="BBQ">
<option value="222">Fried</option>
</optgroup>
</catalog>
how do i read it so that i would have label in the select list and then value and text in item?
i have this and dont know where to go from there.
For Each productnode In nodelist
If productnode.Attributes.Cou
For Each productsubnode In productnode.ChildNodes
'add to child list box
ListBox_Section1.Items.Add
Next
End If
Next
Dim groupNodes As XmlNodeList = doc.SelectNodes("/catalog/ optgroup")
Dim output As New System.Text.StringBuilder
output.Append("<Select>")
For Each node As XmlNode In groupNodes
output.AppendFormat("<opti on group=""{0}"" />", node.Attributes(0).Value)
Dim students As XmlNodeList = node.ChildNodes()
For Each snode As XmlNode In students
output.AppendFormat("<opti on value=""{0}"" >{1}</option>", snode.Attributes(0).Value, snode.InnerText)
Next
Next
output.Append("<Select>")
Dim output As New System.Text.StringBuilder
output.Append("<Select>")
For Each node As XmlNode In groupNodes
output.AppendFormat("<opti
Dim students As XmlNodeList = node.ChildNodes()
For Each snode As XmlNode In students
output.AppendFormat("<opti
Next
Next
output.Append("<Select>")
ASKER
the only thing i got out of your code is <select> <select>
Use XmlDocument Class.
you can find example at following link.
http://www.c-sharpcorner.com/UploadFile/mahesh/ReadWriteXMLTutMellli2111282005041517AM/ReadWriteXMLTutMellli21.aspx