Here is my code:
____________________________________________________
Imports System.Xml
Module XMLMerge
Sub MergeXML(ByVal XMLPath As String, ByVal XMLFile1 As String, ByVal XMLFile2 As String, ByVal XMLFile3 As String)
Dim xmlreader1 As New XmlTextReader(XMLPath & XMLFile1)
Dim xmlreader2 As New XmlTextReader(XMLPath & XMLFile2)
Dim xmlreader3 As New XmlTextReader(XMLPath & XMLFile3)
Dim ds1 As New DataSet()
Try
ds1.ReadXml(xmlreader1)
Dim ds2 As New DataSet()
ds2.ReadXml(xmlreader2)
Dim ds3 As New DataSet()
ds3.ReadXml(xmlreader3)
ds1.Merge(ds2)
ds1.Merge(ds3)
ds1.WriteXml(XMLPath & "FinalFile.XML", XmlWriteMode.IgnoreSchema)
Console.WriteLine("Completed merging XML documents"
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Console.Read()
End Sub
End Module
___________________________________________________
The resulting XML file is read by another application and uses the data to fill out a form. In this XML file are several elements that relate to checkboxes on the form.
XMLFile1:
<?xml version="1.0" ?>
<Form>
<FormData FieldName="CheckBox1">X</FormData>
<FormData FieldName="CheckBox2">X</FormData>
<FormData FieldName="Checkbox3"> </FormData>
</Form>
XMLFile2:
<?xml version="1.0" ?>
<Form>
<FormData FieldName="CheckBox4">X</FormData>
<FormData FieldName="CheckBox5"> </FormData>
<FormData FieldName="Checkbox6">X</FormData>
</Form>
When I merge the documents this is the result:
<?xml version="1.0" ?>
<Form>
<FormData FieldName="CheckBox1">X</FormData>
<FormData FieldName="CheckBox2">X</FormData>
<FormData FieldName="Checkbox3" />
<FormData FieldName="CheckBox4">X</FormData>
<FormData FieldName="CheckBox5" />
<FormData FieldName="Checkbox6">X</FormData>
</Form>
I need to preserve the whitespace in the elements in order to clear the checkbox if it is already checked.
I have tried using the { xml:space = "preserve" } Tag
Please Help......
Persistence....Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. -Calvin Coolidge
Persistence....Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. -Calvin Coolidge
____________________________________________________
Imports System.Xml
Module XMLMerge
Sub MergeXML(ByVal XMLPath As String, ByVal XMLFile1 As String, ByVal XMLFile2 As String, ByVal XMLFile3 As String)
Dim xmlreader1 As New XmlTextReader(XMLPath & XMLFile1)
Dim xmlreader2 As New XmlTextReader(XMLPath & XMLFile2)
Dim xmlreader3 As New XmlTextReader(XMLPath & XMLFile3)
Dim ds1 As New DataSet()
Try
ds1.ReadXml(xmlreader1)
Dim ds2 As New DataSet()
ds2.ReadXml(xmlreader2)
Dim ds3 As New DataSet()
ds3.ReadXml(xmlreader3)
ds1.Merge(ds2)
ds1.Merge(ds3)
ds1.WriteXml(XMLPath & "FinalFile.XML", XmlWriteMode.IgnoreSchema)
Console.WriteLine("Completed merging XML documents"
Catch ex As Exception
Console.WriteLine(ex.Message)
End Try
Console.Read()
End Sub
End Module
___________________________________________________
The resulting XML file is read by another application and uses the data to fill out a form. In this XML file are several elements that relate to checkboxes on the form.
XMLFile1:
<?xml version="1.0" ?>
<Form>
<FormData FieldName="CheckBox1">X</FormData>
<FormData FieldName="CheckBox2">X</FormData>
<FormData FieldName="Checkbox3"> </FormData>
</Form>
XMLFile2:
<?xml version="1.0" ?>
<Form>
<FormData FieldName="CheckBox4">X</FormData>
<FormData FieldName="CheckBox5"> </FormData>
<FormData FieldName="Checkbox6">X</FormData>
</Form>
When I merge the documents this is the result:
<?xml version="1.0" ?>
<Form>
<FormData FieldName="CheckBox1">X</FormData>
<FormData FieldName="CheckBox2">X</FormData>
<FormData FieldName="Checkbox3" />
<FormData FieldName="CheckBox4">X</FormData>
<FormData FieldName="CheckBox5" />
<FormData FieldName="Checkbox6">X</FormData>
</Form>
I need to preserve the whitespace in the elements in order to clear the checkbox if it is already checked.
I have tried using the { xml:space = "preserve" } Tag
Please Help......
Persistence....Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. -Calvin Coolidge
Persistence....Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. -Calvin Coolidge