admin管理员组

文章数量:1314496

I have an XML file shaped something like the file below. I need to provide editing capability to the client via browser in some kind of form/dialog/popup view where the user can edit their name/address, see the list of Autos, add/edit/delete each auto and within each Auto add/edit/delete each feature. On Save, I need to put things pack together into an XML file.

On the Server I'm using ASP.NET and on the browser, I can use javascript, jquery or ASP.NET controls.

So, I'm looking for remendations on the best approach for this, and tools which can manage this. I've tried using jquery to pull information out of the XML, but could not figure out how to update the XML or make the lists of items.

<?xml version="1.0" encoding="utf-8"?>
<Main>
  <FirstName>FirstName</FirstName>
  <LastName>LastName</LastName>
  <Address>123 Somewhere</Address>
  <Year>2007</Year>
  <Autos>
    <Auto>
      <Make>Ford</Make>
      <Model>Mustang</Model>
      <Features>
          <Features>
              <Feature>Convertable</Feature>
          </Features>
      </Features>
    </Auto>
    <Auto>
      <Make>Hyundia</Make>
      <Model>Santa Fe</Model>
      <Variant>GLE</Variant>
      <Features>
          <Feature>Convertable</Feature>
          <Feature>FourWheelDrive</Feature>
          <Feature>RoofRails</Feature>
      </Features>
    </Auto>
  </Autos>
</Main>

I have an XML file shaped something like the file below. I need to provide editing capability to the client via browser in some kind of form/dialog/popup view where the user can edit their name/address, see the list of Autos, add/edit/delete each auto and within each Auto add/edit/delete each feature. On Save, I need to put things pack together into an XML file.

On the Server I'm using ASP.NET and on the browser, I can use javascript, jquery or ASP.NET controls.

So, I'm looking for remendations on the best approach for this, and tools which can manage this. I've tried using jquery to pull information out of the XML, but could not figure out how to update the XML or make the lists of items.

<?xml version="1.0" encoding="utf-8"?>
<Main>
  <FirstName>FirstName</FirstName>
  <LastName>LastName</LastName>
  <Address>123 Somewhere</Address>
  <Year>2007</Year>
  <Autos>
    <Auto>
      <Make>Ford</Make>
      <Model>Mustang</Model>
      <Features>
          <Features>
              <Feature>Convertable</Feature>
          </Features>
      </Features>
    </Auto>
    <Auto>
      <Make>Hyundia</Make>
      <Model>Santa Fe</Model>
      <Variant>GLE</Variant>
      <Features>
          <Feature>Convertable</Feature>
          <Feature>FourWheelDrive</Feature>
          <Feature>RoofRails</Feature>
      </Features>
    </Auto>
  </Autos>
</Main>
Share Improve this question asked Oct 10, 2013 at 14:06 rwgrwg 9349 silver badges12 bronze badges 4
  • 1 well, to begin with you might need to write some html that would support that data, then parse the xml with asp, output the values of the xml into the form, then allow the user to edit it. When they're done, send the data to asp and let asp update the xml. – Kevin B Commented Oct 10, 2013 at 14:11
  • That's the approach my pany remended, load the XML to Asp.NET, write the forms like Main and ListOfAutos in a Grid, then they pick an Auto do a new web page of the Auto with ListOfFeathers and so on. Since I am loading the XML data from the client machine, then letting the user edit it, then sending to the server for final processing, I was kind of hoping for a client side edit before dealing with the server, or at least a reduction in number of server trips and web pages. – rwg Commented Oct 10, 2013 at 14:42
  • 1 Do you need to support legacy browsers? with the fileapi you might be able to do more client-side, but without it you'll have to rely on the server. – Kevin B Commented Oct 10, 2013 at 14:48
  • Unless of course you instead require the user to copy-paste the contents of the xml into your page, but that hardly seems user-friendly. – Kevin B Commented Oct 10, 2013 at 14:51
Add a ment  | 

1 Answer 1

Reset to default 8

If you are looking for a plete JQuery editor plugin, you should check JQuery XML Editor (demo). That's a very plete and heavy plugin, so you may not need all the functionalities, but you can adapt this to fit what you need or just take a look about the codes to help you begin your project.

You should also check Live XML Edit (demo), which is lightweight JQuery XML editing script. It may also interest you because it will be much easier to understand first than JQuery XML Editor as it provides less functionalities.

Edit : Both are client-sided and Live XML Edit is under MIT license.

Hope I helped you !

本文标签: javascriptSuggestions for best methods to edit XML in browserStack Overflow