Click here to Skip to main content
16,007,163 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: File Sharing Violation Problem - Remoting Pin
Steve Pullan12-Sep-05 14:00
Steve Pullan12-Sep-05 14:00 
GeneralRe: File Sharing Violation Problem - Remoting Pin
PranjalSharma12-Sep-05 23:33
PranjalSharma12-Sep-05 23:33 
QuestionKerberos in WSE3.0 &vb.net Pin
haraldsm12-Sep-05 2:13
haraldsm12-Sep-05 2:13 
QuestionEXIF and decoding Makernote data Pin
dazfl12-Sep-05 2:06
dazfl12-Sep-05 2:06 
QuestionClass Conversion Issue Pin
Jason Stamp12-Sep-05 0:03
Jason Stamp12-Sep-05 0:03 
QuestionAppending XML Pin
nitin_ion11-Sep-05 23:08
nitin_ion11-Sep-05 23:08 
AnswerRe: Appending XML Pin
Gavin Jeffrey11-Sep-05 23:46
Gavin Jeffrey11-Sep-05 23:46 
GeneralRe: Appending XML Pin
nitin_ion12-Sep-05 1:35
nitin_ion12-Sep-05 1:35 
Say i have this Xml file

<Books>
<Book type="1">
<Author>Peter</Author>
<Section>1</Section>
</Book>
</Books>
and when i add one more book then i want the output to be
<Books>
<Book type="1">
<Author>Peter</Author>
<Section>1</Section>
</Book>
<Book type="2">
<Author>Johnr</Author>
<Section>2</Section>
</Book>
</Books>


the code i am using

Dim WriteXMLFile As XmlTextWriter
Dim fs As FileStream = New FileStream("C:\Err.xml", FileMode.Open)Dim reader As New XmlTextReader(fs)
Dim reader As New XmlTextReader(fs)
WriteXMLFile = New XmlTextWriter(fs, ISOEncode)

Dim doc As New Xml.XmlDocument
'load file
doc.Load(fs)
Dim root As XmlNode = doc.SelectSingleNode("//Books")

If root Is Nothing Then
'if this is a new document create root
root = doc.SelectSingleNode("//Books")
Else
'create node
'get root node named users
Dim Usersnode As Xml.XmlElement = doc.SelectSingleNode ("//Books")
'add the new node
Dim newNode As Xml.XmlElement = doc.CreateElement("Book")
'add attributes
newNode.SetAttribute("type", m)
'add children nodes if any
Dim child As Xml.XmlElement = doc.CreateElement("Author")
child.InnerText = txtAuthor.Text
newNode.AppendChild(child)
child = doc.CreateElement("Section")
child.InnerText = txtSection.Text
newNode.AppendChild(child)
'add new node to users node
Usersnode.AppendChild(newNode)
m += 1
End If
'save doc
doc.Save(fs)

The output i am getting

<?xml version="1.0"?>
<Books>
<Book type="1">
<Author>Peter</Author>
<Section>1</Section>
</Book>
</Books><?xml version="1.0"?>
<Books>
<Book type="1">
<Author>Peter</Author>
<Section>1</Section>
</Book>
<Book type="2">
<Author>Johnr</Author>
<Section>2</Section>
</Book>
</Books>


Can you help?
GeneralRe: Appending XML Pin
Gavin Jeffrey12-Sep-05 20:32
Gavin Jeffrey12-Sep-05 20:32 
QuestionI get a error from Crystal report 10.0. Pin
Jimmy Huynh11-Sep-05 22:54
Jimmy Huynh11-Sep-05 22:54 
QuestionDatagrid Pin
mcgann11-Sep-05 21:49
mcgann11-Sep-05 21:49 
AnswerRe: Datagrid Pin
LeenaSo11-Sep-05 22:48
LeenaSo11-Sep-05 22:48 
Questioninput box Pin
ali kanju11-Sep-05 18:34
ali kanju11-Sep-05 18:34 
AnswerRe: input box Pin
Christian Graus11-Sep-05 18:50
protectorChristian Graus11-Sep-05 18:50 
AnswerRe: input box Pin
Briga11-Sep-05 22:29
Briga11-Sep-05 22:29 
AnswerRe: input box Pin
MohammadAmiry12-Sep-05 20:02
MohammadAmiry12-Sep-05 20:02 
Questionarray of control Pin
ali kanju11-Sep-05 18:29
ali kanju11-Sep-05 18:29 
AnswerRe: array of control Pin
Christian Graus11-Sep-05 18:51
protectorChristian Graus11-Sep-05 18:51 
AnswerRe: array of control Pin
rwestgraham11-Sep-05 18:52
rwestgraham11-Sep-05 18:52 
Questiontelephone number format question Pin
rolfjahn11-Sep-05 17:36
rolfjahn11-Sep-05 17:36 
AnswerRe: telephone number format question Pin
Christian Graus11-Sep-05 17:47
protectorChristian Graus11-Sep-05 17:47 
Questionstore String chars or substrings in Array Pin
Anonymous11-Sep-05 16:04
Anonymous11-Sep-05 16:04 
AnswerRe: store String chars or substrings in Array Pin
Anonymous11-Sep-05 16:06
Anonymous11-Sep-05 16:06 
AnswerRe: store String chars or substrings in Array Pin
Christian Graus11-Sep-05 16:46
protectorChristian Graus11-Sep-05 16:46 
AnswerRe: store String chars or substrings in Array Pin
Scott Page12-Sep-05 10:29
professionalScott Page12-Sep-05 10:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.