hello aLL
I'm using VB.Net
I'm using writer = New XmlTextWriter (.......
to careate an xml file
I need to change an element after i have built it !!!
how
hello aLL
I'm using VB.Net
I'm using writer = New XmlTextWriter (.......
to careate an xml file
I need to change an element after i have built it !!!
how
how to update element while create a file
Robert Franks
Thanks for explanation of details.
It makes sense.
The best you can do is to determine state of the flag before you start writing XML file.
If you can't read DB twice you can generate XML in memory by adding node to XmlDocument tree. (There are many ways of doing this. One above uses XmlWriter.)
After document created change/add flag attribute on "Header" element.
Write/send XmlDocument.
Of cause you can also save your document on disk or memory stream and then change flag attribute there. For this you can use XML tools (XmlReader/XmlWriter) of treat it as a text file and change one byte there.
jebrown
XmlTextWriter writes XML nodes to stream or file.
Most likely you write it to file.
After you write your XML it is in the file and you can modify it as any other text file on your system. (I.e. open it in Notepad or do this programmatically.)
To edit it as an XML you can load it to XmlDocument, modify there and save back.
If you know in advance that you'd need to change this file -- don't save it to disk, but instead write it to XmlDocument directly.
d = new XmlDocument();
writer = d.DocumentElement.CreateNavigator().AppendChild();
... use this writer ...
writer.Close();
Now you can modify the document before saving it.
Tommy8890
hi again
It is Ok now
I had used xmldocument
first of all close writer instance
then recorrect flaq value with xml document :)
but I prefer to be while I'm creating XML file not after..
MicahN
Ok, let me explain it more
I have to send an XML file.
this file created by me - reading from database -
the xml file divided to multi section
<Header>
<Info1>
<info2>
<info3>
now the Header section has an element called Flag tell if the Xml has a new data or not, after I finish reading from database and create elements, I will be aware if there is new data or not. If there is a data Flag will equal 0 unless will equal 1.
So, the default value for Falg equals to 1, but befor finish WRITER object, I need to change that value to 0 if there is a new data else leave it as it is.
Did u get it
Borislav
Sorry.
I don't understand your last sentence: "but I prefer to be while I'm creating XML file not after..".
Do you what to do everything in one pass (in "streaming manner") without fixing information you generated already This is the best thing from performance point of view you can do, but it is not always possible and contradicts your first question.