Link to home
Start Free TrialLog in
Avatar of Easwaran Paramasivam
Easwaran ParamasivamFlag for India

asked on

Console application to manipulate XML in .NET using C#

Hi Experts,

 Please refer below sample xml.  I would like to develop a console applications in C# in a such a way that they solve below problems. Could you please suggest how to achieve? Thanks in advance!

1. Add or Update/Delete existing Person
Say for instance if user chooses Update option it should ask which Person he needs to update and what details should be updated (ex. Age value should be modified as 55

<PersonDetails>
   <Person>
     <Name>Easwar</Name>
     <Age>26</Age>
   </Person>
<Person>
     <Name>Baskar</Name>
     <Age>24</Age>
   </Person>
<PersonDetails>

Open in new window


2. For existing Person, if address details need to be added, it should add accordingly. The program should be generic in such a way that I could add qualification details later point as same as address.

<PersonDetails>
   <Person>
     <Name>Easwar</Name>
     <Age>26</Age>
      <Address>
           <Street>Gandhi nagar</Street>
            <City>Mumbai<City>
            <PinCode>4000234</PinCode>
      <Address>
   </Person>
<Person>
     <Name>Baskar</Name>
     <Age>24</Age>
   </Person>
<PersonDetails>

Open in new window

Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

first fix your xml the corrected version is below.. Garbage in, Garbage Out.
<?xml version="1.0" encoding="utf-8" ?>
<PersonDetails>
  <Person>
    <Name>Easwar</Name>
    <Age>26</Age>
    <Address>
      <Street>Gandhi nagar</Street>
      <City>
        Mumbai<City>
          <PinCode>4000234</PinCode>
          </Address>
   </Person>
  <Person>
    <Name>Baskar</Name>
    <Age>24</Age>
  </Person>
  </PersonDetails>

Open in new window

SOLUTION
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Easwaran Paramasivam

ASKER

This answers the first part of the question. Could you please provide the second query? Thanks!
Honestly, I haven't got your second question. Could you please explain in more details what you want?
Well. In the XML, say for instance a person XML contains some nodes exists already such as first name, last name. Assume that this is from a third party application output. I want to add an address node for a particular person as given in the sample in the question. Likewise I need to develop a dynamic program which should allow other nodes as well later such as qualification. Could you please assist?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial