I'm writing a little program that works with xml files, everything goes well except deleting nodes.
let's say i've this in my xml file:
After deleting nod 6910217 it looks like this:
Please note the added hard returns (or whatever they are) within the empty fields of the non-deleted records.
Is there a way to remove these 'hard returns'? Cause they are giving me errors within an other part of my coding.
This is my delete part:
let's say i've this in my xml file:
Code:
<?xml version="1.0"?>
<collection shelf="mine">
<Item ID="6910217">
<artikel>hmmm</artikel>
<titel>titel</titel>
<prijs>prijs</prijs>
<foto1>ft1</foto1>
<foto2>ft2</foto2>
<foto3>ft3</foto3>
<foto4>ft4</foto4>
<foto5></foto5>
<foto6>ft6</foto6>
<foto7>ft7</foto7>
<foto8>ft8</foto8>
<omschrijving>advetekst</omschrijving>
</Item>
<Item ID="6910216">
<artikel>test</artikel>
<titel>title</titel>
<prijs>price</prijs>
<foto1>ft1</foto1>
<foto2>ft2</foto2>
<foto3>ft3</foto3>
<foto4>ft4</foto4>
<foto5></foto5>
<foto6></foto6>
<foto7></foto7>
<foto8></foto8>
<omschrijving>some text</omschrijving>
</Item>
</collection>
Code:
<?xml version="1.0"?>
<collection shelf="mine">
<Item ID="6910216">
<artikel>test</artikel>
<titel>title</titel>
<prijs>price</prijs>
<foto1>ft1</foto1>
<foto2>ft2</foto2>
<foto3>ft3</foto3>
<foto4>ft4</foto4>
<foto5>
</foto5>
<foto6>
</foto6>
<foto7>
</foto7>
<foto8>
</foto8>
<omschrijving>some text</omschrijving>
</Item>
</collection>
Is there a way to remove these 'hard returns'? Cause they are giving me errors within an other part of my coding.
This is my delete part:
Code:
Private Sub delete_Click(sender As System.Object, e As System.EventArgs) Handles delete.Click
Dim yd As New XmlDocument()
yd.Load("c:\item_list.xml")
Dim nod As XmlNode = yd.SelectSingleNode("collection/Item[@ID='" & ListBox13.Items(ListBox1.SelectedIndex + 1).ToString & "']")
If nod IsNot Nothing Then
nod.ParentNode.RemoveChild(nod)
yd.Save("c:\item_list.xml")
Application.Restart()
Else
MsgBox("not found")
End If
End Sub