XML Editing

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Ive recently started using C# 2005 (simply because I got a free license for it from a class I was taking, and I dont want to pay for 2008.) Anyhow, Im in the process of writing what is essentially an XML reader. I also need to be able to add/remove entries from the XML file. For example, say this was my XML document:

<div style="overflow:auto;background-color:white;line-height:100% ! important;font-family:Courier New;font-size:11px <table style="border-width:0px;margin:2px 0px;width:99%;border-collapse:collapse;background-color:rgb(255, 255, 255)" cellpadding=0 cellspacing=0><col style="border-right:1px solid gray;font-family:Courier New;font-size:11px;background-color:rgb(238, 238, 238);padding-right:5px;padding-left:10px;width:5px;color:gray;text-align:right;vertical-align:top <col style="font-family:Courier New;font-size:11px;padding-left:10px;white-space:nowrap <tbody><tr><td><nobr>1</nobr></td><td><font style="font-size:11px </font><font style="color:blue <?</font><font style="font-size:11px xml </font><font style="color:red version</font><font style="font-size:11px =</font><font style="color:blue "1.0"</font><font style="font-size:11px ?> </font></td></tr><tr><td><nobr>2</nobr></td><td style="background-color:rgb(247, 247, 247) <font style="color:blue <</font><font style="font-size:11px members</font><font style="color:blue ></font><font style="font-size:11px  </font></td></tr><tr><td><nobr>3</nobr></td><td>     <font style="color:blue <</font><font style="font-size:11px member_01</font><font style="color:blue ></font><font style="font-size:11px  </font></td></tr><tr><td><nobr>4</nobr></td><td style="background-color:rgb(247, 247, 247)           <font style="color:blue <</font><font style="font-size:11px Name</font><font style="color:blue ></font><font style="font-size:11px John Doe</font><font style="color:blue </</font><font style="font-size:11px Name</font><font style="color:blue ></font><font style="font-size:11px  </font></td></tr><tr><td><nobr>5</nobr></td><td>     <font style="color:blue </</font><font style="font-size:11px member_01</font><font style="color:blue ></font><font style="font-size:11px  </font></td></tr><tr><td><nobr>6</nobr></td><td style="background-color:rgb(247, 247, 247)      <font style="color:blue <</font><font style="font-size:11px member_02</font><font style="color:blue ></font><font style="font-size:11px  </font></td></tr><tr><td><nobr>7</nobr></td><td>          <font style="color:blue <</font><font style="font-size:11px Name</font><font style="color:blue ></font><font style="font-size:11px Jane Smith</font><font style="color:blue </</font><font style="font-size:11px Name</font><font style="color:blue ></font><font style="font-size:11px  </font></td></tr><tr><td><nobr>8</nobr></td><td style="background-color:rgb(247, 247, 247)      <font style="color:blue </</font><font style="font-size:11px member</font><font style="color:blue ></font><font style="font-size:11px  </font></td></tr><tr><td><nobr>9</nobr></td><td><font style="color:blue </</font><font style="font-size:11px members</font><font style="color:blue ></font><font style="font-size:11px  </font></td></tr><tr><td><nobr>10</nobr></td><td style="background-color:rgb(247, 247, 247)  </td></tr></tbody></table>
Is there a function I can use to add a new "member" to the bottom, or will I have to parse through the file line-by-line and add one before the final tag?


View the full article
 
Back
Top