Saving XML Files - XML Editing PLEASE HELP
Hello there,
My name is Kedhrin, I'm new to VB and i've only been using it for one day now. I'm making a simple application in Visual Basic 2005 Express Edition that will let me edit XML Files... visually!
They are only one specific XML file, and there is 9 fields where the values can change.
I have everything implemented in, everything all set to go
except.
I don't know how to save the file, I have the save dialog button rigged all up by i kind of halt after
SaveFileDialog1.ShowDialog()
If ShowDialog.OKThenThats when I don't know what to do or what to put for saving my fields back into the XML file.I've been searching all over the net, and I'm finding things for VB6 only really. Things are much easier and faster in Express, I was able to load the XML file and all my values quickly and without very much. So everything is in, all my value changes, etc. all work correctly (which i'm very pleased with).
Now, to write the XML file!!!!
please help :(
i need this done tonight, so please get back to me ASAP.
Thank you!
[1240 byte] By [
Kedhri] at [2008-3-6]
Thanks for a quick reply Paul,
I know what the XmlWriter is,
and i read that page, and all the pages related to it. But it still doesn't describe how to use it. I've only been using Visual Basic for one day, and I've gotten this far to the point where I need to save the file and i'll be done.
I have the .xml file loaded on file load (or even default when you load the program)
as...
| | Dim m_xmlr As XmlTextReader m_xmlr = New XmlTextReader("env_time_midday_nfx.xml") |
how would i call upon that load to XmlWrite, and i still don't understand how its defining it. All I want it to do is use the same exact format as the XML file loaded, replace the values i defined, that i changed with my visual GUI, and then use a Save As feature.
help plzz!! i've been working on this for my weekend off from work, i'd like to go watch tv and relax soon :(
Hey Paul,
That does make more sense,
however, i don't want to save it to a specific path every time as i have a "save as" button, the whole purpose of the editor is to create new xml files as well.
this is the error i get...
Invalid XML document, The document does not have a root element..
i need it to save to whatever file i put into the save as dialog
"SaveFileDialog1.Filename"I'm thinking the TextWriter method might be the best solution it has listed.
my xml Load is
"m_xmlr = New XmlTextReader(OpenFileDialog1.FileName)"i'm reading their info on TextWriter but again it doesn' tell how to use it, it has the Usage field and i tried typing in what they have and matching my values to it and it still wouldn't work.
every time i try to edit i always get the same errors
"Local variable 'blah' is laready declared in the current block."
if i remove it i get
"Unused local variable: 'blah'"
or
"Variable 'blah' is used before it has been assigned a value. A null reference exception could result at runtime."
I need it to use a Save As feature, not save to the loaded XML file, that is there for the regular Save button.