Generare XML - XmlDocument and XmlElement - need some help?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am away from my office PC now, so i can't get my problem codes up.

I can achieve this in C# with xmldocument and xmlelement

<Device>
<ExecuteProcess1 />
<ExecuteProcess2>
Test
</ExecuteProcess2>
<ExecuteProcess3>
123
</ExecuteProcess3>
</Device>

But, when i try to generate more than this...

<Device>
<ExecuteProcess1 />
<ExecuteProcess2>
<DeviceName>IBM PC</DeviceName> // not sure how to get it to be part of
ExecuteProcess 2
<DeviceLength>6</DeviceLength> // not sure how to get it to be part of
ExecuteProcess 2
</ExecuteProcess2>
<ExecuteProcess3>
<Calculate id="1">123</Calculate> // not sure how to get it to be part
of ExecuteProcess 3 and place id right here!
</ExecuteProcess3>
</Device>

I fail a lot of times when i try to do like above and always get the
results to be like this below.

<Device>
<ExecuteProcess1 />
<DeviceName>IBM PC</DeviceName>
<DeviceLength>6</DeviceLength>
<ExecuteProcess2>
</ExecuteProcess2>
<Calculate id="1">123</Calculate>
<ExecuteProcess3>
</ExecuteProcess3>
</Device>

Any help? I just want to get things right? Sorry that i can't attached my
code here at home but can anyone share some thoughts on this please -
probably some code snippets :)

Cheers.
 
To clarify, your struggling with the code that makes DeviceName /
DeviceLength / Calculate nodes children of the relevant ExecuteProcess's?

I suspect your referencing the "Device" node when adding these children,
rather than the ExecuteProcess nodes into which you want to place them.

If you post your code we'll be able to steer where you're going wrong.

Dan.
 
Back
Top