Manipulate xml through linq

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Is it possible to update the following xml structure through linq.
I want to add UnitTest, TestList, TestEntry and UnitTestResults elements through code.

<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <?<span style="color:#A31515; xml <span style="color:Red; version<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1.0<span style="color:Black; " <span style="color:Red; encoding<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; UTF-8<span style="color:Black; "<span style="color:Blue; ?>
<span style="color:Blue; <<span style="color:#A31515; TestRun <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; 1<span style="color:Black; " <span style="color:Red; xmlns<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; http://microsoft.com/schemas<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; TestDefinitions<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; UnitTest <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Test1<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; T1<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Execution <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; E1<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; UnitTest<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; UnitTest <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Test2<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; T2<span style="color:Black; "<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Execution <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; E2<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; </<span style="color:#A31515; UnitTest<span style="color:Blue; >
:
:

<span style="color:Blue; </<span style="color:#A31515; TestDefinitions<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; TestLists<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; TestList <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; List1<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L1<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; TestList <span style="color:Red; name<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; List2<span style="color:Black; " <span style="color:Red; id<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L2<span style="color:Black; " <span style="color:Blue; />
:
:

<span style="color:Blue; </<span style="color:#A31515; TestLists<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; TestEntries<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; TestEntry <span style="color:Red; testId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; T1<span style="color:Black; " <span style="color:Red; executionId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; E1<span style="color:Black; " <span style="color:Red; testListId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L1<span style="color:Black; " <span style="color:Blue; />
<span style="color:Blue; <<span style="color:#A31515; TestEntry <span style="color:Red; testId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; T2<span style="color:Black; " <span style="color:Red; executionId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; E2<span style="color:Black; " <span style="color:Red; testListId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; L2<span style="color:Black; " <span style="color:Blue; />
:
:
<span style="color:Blue; </<span style="color:#A31515; TestEntries<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Results<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; UnitTestResult <span style="color:Red; executionId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; E1<span style="color:Black; " <span style="color:Red; testId<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; T1<span style="color:Black; " <span style="color:Red; testName<span style="color:Blue; =<span style="color:Black; "<span style="color:Blue; Test1<span style="color:Black; " <span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Output<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; ErrorInfo<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Message<span style="color:Blue; >Hi<span style="color:Blue; </<span style="color:#A31515; Message<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; ErrorInfo<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Output<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; UnitTestResult<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; Results<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; Results<span style="color:Blue; >
:
:
<span style="color:Blue; </<span style="color:#A31515; TestRun<span style="color:Blue; >

[/code]
<hr class="sig Regards,<br/>
http://jaydeeppatil.co.cc Jaydeep

View the full article
 
Back
Top