troubleshooting Question

Edit XML file with ASP.NET

Avatar of LordSM
LordSM asked on
XMLASP.NET
3 Comments3 Solutions1108 ViewsLast Modified:
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>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 3 Answers and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros