sachi vasishta

sachi vasishta

  • NA
  • 252
  • 0

How to read data from XML to textbox dynamically and how to write to XML file from the textbox

Dec 2 2011 4:47 AM

Hi All,

I have a following XML file (Auto.xml)

<root>
  <fault>
    <text selected_value="Pending fault">Pending Fault found on</text> 
    <text selected_value="Already repaired">Repaired Fault on</text>   
  </fault>
  <genere>
    <text>Aircraft</text>
    <text>Component</text>
    <text>Subsystem</text>
  </genere>
</root>

Now what I want is, I have an aspx page there I want to have the design as below.

Fault Category(a label control): two radio buttons(a radiobuttonlist control with the values 1. hardcode 2. database)

now if I select 'hardcode' radiobutton then 2*n (where n is the number of nodes under fault element i.e., 4) text boxes should appear (two textboxes per row) below the Fault category label.

In the first row,the first textbox should show the value of the first text node under the fault element(i.e.,'Pending Fault found on') and the second textbox should show the attribute value of the first text node under the fault element(i.e.,'Pending fault') and in second row it should show the same for second text node.

After it displays the values,in third row I want to have a button with the text 'Add new Value'. If I click this button then a new row should appear with two text boxes and a button with the text 'Add'. I will enter some text in those two textboxes and click on 'add' button. After this the first text value should be appended in the XML file (as the third text element under the fault node) and the second text value should be appended in the XML as the attribute value for the third element under fault node(and the same should reflect in aspx file).

For example if the first text value is 'Checking Fault on' and the second text value is 'Already Checked' then in Auto.xml file

<root>
  <fault>
    <text selected_value="Pending fault">Pending Fault found on</text> 
    <text selected_value="Already repaired">Repaired Fault on</text>  
    <text selected_value> ="Already checked">Checking Fault on</text>  // this has to come from the text boxes that I will add from the aspx file
  </fault>
  <genere>
    <text>Aircraft</text>
    <text>Component</text>
    <text>Subsystem</text>
  </genere>
</root>

How to achieve this ?

Thanks,
Sachi