ASP.NET update XML from GridView

Hi Experts,

     I  am writing an  ASP.NET application  to read an XML file show it in a Gridview and do insert/update/delete  done in grid reflected  back in XML File

     I have the standard code for making it happen for the standard XML format . All works fine with no issues

    But My XML Hierarchy is as follows    ( Loosely speaking, You can consider it as   Branches  of an office as root nodes  and Employee details under it . The issue is there are multiple root node as below)

      <Branch1 Description = "N1Description>
          <Employee>  
             <Name> TestName1 </Name>
            <Position> Pos1 </Position>
         <Employee>
           <Employee>  
             <Name> TestName2 </Name>
            <Position> Pos2 </Position>
         <Employee>
               ...........
     </Branch1>

    <Branch2  Description = "N2Description>
         <Employee>  
             <Name> TestName21 </Name>
            <Position> Pos21 </Position>
         <Employee>
            ..........................
     </Branch2>

       ......

   
      Can I take just one node out of it ( say Branch1)  and show EmployeeDetails  in GridView    and Update the details  ?   Infact , It is the update /insert/delete  that I am more concerned to do as showing on grid is not an issue   . Is there a way of achieving this ?  
 
     I need just the code for 1)  filling the Dataset/Datatable from XML file    and   2)   Writing back to XML      - BUT HONORING THE STRUCTURE OF MY XML
Sam OZAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rafiq J.Net DeveloperCommented:
This link would help you perfectly..

kindly revert us if u have any query.....

http://www.c-sharpcorner.com/UploadFile/4b0136/performing-insert-update-delete-in-xml-in-Asp-Net/
Sam OZAuthor Commented:
Hi,

  Thanks for the link. But I already have things working in a similar way .

    in my case the branches go as   <Student1>  <Student2>     instead of <Student>  
    Also, In my case it will be like School1, School2   and then show the student details in a given school

    Infact , IF SOMEONE CAN TELL HOW TO  refer a table in Dataset by some ID    ( along with the XML structure for that) , it may be good enough for me . I need call by Id for a different routine

    If I keep the structure like
      <School  ID = "School1" >
           ..... Sub nodes of Students
       </School>
     
        <School  ID = "School2" >
           ..... Sub nodes of Students
       </School>

       From this NodeList how can I call a  School Node  by it's ID  ( say, School1)
Rafiq J.Net DeveloperCommented:
<schools>
<School  ID = "School1" >
           ..... Sub nodes of Students
       </School>
     
        <School  ID = "School2" >
           ..... Sub nodes of Students
       </School>
</schools>

Design in Grid:

 <asp:TemplateField HeaderText="Id" HeaderStyle-Width="50">
            <ItemTemplate>
               <%# XPath("@Id") %>
            </ItemTemplate>
        </asp:TemplateField>

C#- code:
id value is passed by you...

  XmlDataSource1.XPath = "/Schools/school[ id ='" + ID+ "']";

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.