VB.Net/XML/XmlWriter — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 12:42, 26 мая 2010
Append new child to the XmlWriter
Public Class Example8
Shared Sub Main
Dim doc As System.Xml.XmlDocument
Dim editor, editor2 As System.Xml.XPath.XPathNavigator
Dim writer As System.Xml.XmlWriter
doc = New System.Xml.XmlDocument
doc.Load("pubs.xml")
For Each editor In doc.CreateNavigator.Select("/pubs/titles[authors/@au_lname="Green"]")
editor2 = editor.SelectSingleNode("authors[@au_lname!="Green"]")
If Not IsNothing(editor2) Then
editor2.DeleteSelf()
End If
writer = editor.AppendChild()
writer.WriteStartElement("authors")
writer.WriteAttributeString("au_lname", "A")
writer.WriteAttributeString("au_fname", "B")
writer.Close()
Next
doc.Save("output.xml")
End Sub
End Class