hi, thank you for your help but it didn't added to where i want it to be here
is a fragment of xml file that i'm working on
<EventEnrollment InstanceNumber="3747">
<BackwardReferences/>
<EventEnrollmentProperties AckRequired="0" EventEnable="0" EventType="0"
NotifyClass="0" NotifyType="0" PresentValue="0" ToFaultText=""
ToNormalText="" ToOffNormalText="">
<EnabledReference ObjectKey="" PropertyName=""/>
<EventParameters BitMask="0" Deadband="" HighDiffLimit="" HighLimit=""
ListOfBitStringValues="" ListOfValues="" LowDiffLimit="" LowLimit=""
ReferencedPropertyIncrement="1" TimeDelay="60" TimeInterval="1">
<SetpointReference ObjectKey="" PropertyName=""/>
</EventParameters>
<EventSources/>
</EventEnrollmentProperties>
<GeneralProperties Attr="0" InstanceNumber="3747" IsConfigured="0"
ObjectName="test" ObjectType="9" SchemaVer="1.4" TraceOptions="0">
<Description/>
</GeneralProperties>
<EventEnrollment InstanceNumber="9000"/>
</EventEnrollment>
i'll like to create a new EventEnrollment block right after the last
EventEnrollment. how did it got appened into the last EventEnrollment and not
by itself.
"Martin Honnen" wrote:
dotnetnoob wrote:
let's say i have a xml file
<root>
<stuff id='1'>
<stuff1>
</stuff1>
</stuff>
</root>
how do i insert new <stuff2>element and atrribute after stuff1
You can do that with the DOM e.g. (C#)
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(@"file.xml");
xmlElement stuff =
xmlDocument.SelectSingleNode("root/stuff[@id = '1']") as XmlElement;
if (xmlElement != null) {
XmlElement stuff2 = xmlDocument.CreateElement("stuff2");
stuff.AppendChild(stuff2);
}
xmlDocument.Save(@"file.xml");
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/