I am trying to append a child into an xml file.
I need this :
Code:
- <anyT xsi:type="AlarmEvent">
    <GC>12</GC> 
    <SN>14897</SN> 
    <AHigh>70</AHigh> 
    <ALow>35</ALow> 
  </anyT>
Into this:

Code:
<?xml version="1.0" encoding="utf-8" ?> 
- <IST xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="Instrument">
  <hasFeature>false</hasFeature> 
  <hasSFeature>false</hasSFeature>    
- <ss>
  - <aT xsi:type="Sensor">
      <sNumber>1_3_102</sNumber> 
      <type>UNK</type> 
      <sDate>2007-04-20T08:03:38.0000000-04:00</sDate> 
    </aT>
  </ss>
- <bO>
    <aT xsi:type="xsd:int">2</aT> 
  </bO>
  <aE /> 
  </IST>
I am appending the first xml as a child into the aE section. I can get it all to work except the xsi:type = "AlarmEvent" part. It only shows up as type = "AlarmEvent" . I think I have to load the xml's attribute so it can see what xsi is.

Here is the code I am using.

[CODE]
Dim doc As New System.Xml.XmlDocument
doc.Load("C:\file.xml")
Dim node As System.Xml.XmlNode = doc.CreateNode(Xml.XmlNodeType.Element, "anyT", "")
Dim nodeA As System.Xml.XmlAttribute
nodeA = doc.CreateAttribute("xsi:type")
nodeA.Value = "AlarmEvent"
node.Attributes.Append(nodeA)
doc.SelectSingleNode("//aE").AppendChild(node)
doc.Save("C:\file.xml")