Avatar of LordSM
LordSM asked on

Edit XML file with ASP.NET

I have an XML file of the format attached below

I would like to edit values of these field and add new elements in ascending order. How can I program such a parser in ASP.NET?

ex: I could edit SubCategory "Industrial" under "Generators" (Category).
I could add Manufacturer "BG" under "Generators" and it shall be inserted between "Altorfer" and "Caterpillar"

<?xml version="1.0" encoding="utf-8" ?>
<Lookup>
  <Item>
    <Categories>
      <Category Name="Generators">
        <SubCategories>
          <SubCategory Value="Industrial" />
          <SubCategory Value="Marine" />
          <SubCategory Value="Natural Gas" />
        </SubCategories>
        <Manufacturers>
          <Manufacturer Value="Altorfer" />
          <Manufacturer Value="Caterpillar" />
          <Manufacturer Value="Cooper Superior" />
          <Manufacturer Value="Cummins" />
          <Manufacturer Value="Cummins Wartsila" />
        </Manufacturers>
      </Category>
      <Category Name="Engines">
        <SubCategories>
          <SubCategory Value="Industrial" />
          <SubCategory Value="Marine" />
          <SubCategory Value="Power Unit" />
        </SubCategories>
        <Manufacturers>
          <Manufacturer Value="Caterpillar" />
          <Manufacturer Value="Cummins" />
          <Manufacturer Value="Detroit Diesel" />
        </Manufacturers>
      </Category>
      <Category Name="Power Plants">
        <SubCategories>
          <SubCategory Value="Reciprocating" />
          <SubCategory Value="Turbine" />
        </SubCategories>
        <Manufacturers>
          <Manufacturer Value="Allison" />
          <Manufacturer Value="Caterpillar" />
          <Manufacturer Value="Deutz" />
          <Manufacturer Value="Fairbanks Morse" />
          <Manufacturer Value="Leroy Somer" />
        </Manufacturers>
      </Category>
      <Category Name="Turbines">
        <SubCategories>
          <SubCategory Value="Natural Gas" />
          <SubCategory Value="Industrial" />
        </SubCategories>
        <Manufacturers>
          <Manufacturer Value="Caterpillar" />
          <Manufacturer Value="GE" />
          <Manufacturer Value="Fairbanks Morse" />
        </Manufacturers>
      </Category>
      <Category Name="Accessories">
        <SubCategories>
          <SubCategory Value="Compressor" />
          <SubCategory Value="Enclosure" />
          <SubCategory Value="Transmission" />
          <SubCategory Value="Radiator" />
        </SubCategories>
        <Manufacturers>
          <Manufacturer Value="Reintjes" />
          <Manufacturer Value="Silex" />
          <Manufacturer Value="Young" />
          <Manufacturer Value="ZF Marine" />
        </Manufacturers>
      </Category>
    </Categories>
    <Hours>
      <Hour Value="Since New" />
      <Hour Value="Since Rebuilt" />
    </Hours>
    <Availability>
      <AvailableType Value="Sale Pending" />
    </Availability>
  </Item>
  <Expense Name="Expense Types">
    <Type Value="Rental Credit" />
    <Type Value="Credit" />
  </Expense>
  <Note Name="Note Types">
    <Type Value="Delivery" />
    <Type Value="Accessories" />
    <Type Value="Location" />
  </Note>
  <Contacts>
    <Phones>
      <Phone Value="Business" />
      <Phone Value="Mobile" />
      <Phone Value="Fax" />
    </Phones>
    <Addresses>
      <AddressType Value="Billing" />
      <AddressType Value="Business" />
      <AddressType Value="Home" />
      <AddressType Value="Mailing" />
    </Addresses>
  </Contacts>
  <Lead>
    <Sources>
      <Source Value="Returning Customer" />
      <Source Value="IMP Website Inquiry" />
      <Source Value="Industry Trader" />
    </Sources>
    <Reminders>
      <Remind Text="Day(s)" Value="Day" />
      <Remind Text="Week(s)" Value="Week" />
      <Remind Text="Month(s)" Value="Month" />
    </Reminders>
    <Statuses>
      <Status Value="Open" />
      <Status Value="Closed" />
    </Statuses>
  </Lead>
</Lookup>

Open in new window

XMLASP.NET

Avatar of undefined
Last Comment
LordSM

8/22/2022 - Mon
SOLUTION
ororiole

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
funwithdotnet

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23