Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit XML File

Status
Not open for further replies.

ComputersUnlimited

IS-IT--Management
Dec 18, 2013
37
0
6
US
I am trying to write a program that reads in data from an XML file, edit it and writes it back to the file or a new file. This will include adding additional tags.

Although I have used VB before I have never done anything like this.

What is the best way to read the data in from the XML file and write it back or create a new file, including creating new tags? If it matters the user will be selecting the file.

Thank You
 
.NET has a bunch of methods to read/write XML. Here's decent overview of using ADO.NET (DataSet, etc.) to read and write XML files:


Once you get the XML loaded into a DataSet, you can add columns and such, then write the data back to XML.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Thanks jebenson
I just got home from work and am pretty tired from working in the heat. I will read the article you posted after i get a nights worth of sleep.
 
The article above uses datagrids however the version of VB I have available to me (2015 and 2017) use datagridview. I do not know enough of either one to convert them.

However I found this article:

I THINK it may have put me on the right track. However it does not read in all of the data from the XML file. If I set the datagrid member property as follows the grid is populated with filename, channel, status, starttime, endtime and name
Code:
DataGridView1.DataMember = "recording"

however if I set the datamember property as follows the grid is populated with Title, SubTitle, Description, StartTime, EndTime and OID
Code:
DataGridView1.DataMember = "Event"

How can I combine both results into one.

The schema for my XML fill looks like this
XML:
<recordings>
  <recording>
    <filename></filename>
    <channel></channel>
    <status></status>
    <startTime></startTime>
    <endTime></endTime>
    <name></name>
    <Event>
      <Title></Title>
      <SubTitle></SubTitle>
      <Description></Description>
      <StartTime></StartTime>
      <EndTime></EndTime>
      <OID></OID>
    </Event>
  </recording>
</recordings>

Thank You
 
I have a couple of other questions

[ol 1]
[li]How can I add entries after

XML:
 <EndTime></EndTime>

and before

XML:
<OID></OID>
[/li]

[li]Is it possible to use other controls such as text boxes to enter or change values in the record set? If so how[/li]
[/ol]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top