开发者

Edit Xml from web forms

开发者 https://www.devze.com 2023-03-03 00:43 出处:网络
Here is a newbie who needs your help.I have an xml file and I want to edit the value of ea开发者_StackOverflow中文版ch element from a web form and generate the editted xml file using rails:Eg. I want

Here is a newbie who needs your help.I have an xml file and I want to edit the value of ea开发者_StackOverflow中文版ch element from a web form and generate the editted xml file using rails:Eg. I want to change the Type of book from Hardcover to Softcopy from a web form and after I will generate the new xml file . I imagine I have to import the xml file to my application and my application show me the xml in grid and I will edit it and generate the new xml. here is the structure of my xml file

<null id_ref="null"/>
<Catalog id_ref="A0">
   <Books>
        <Book id_ref="A1">
           <Name>rails</Name>
           <Type>Hardcover</Type>
           <Modifiers>        
               <Modifier id_ref="A2">
                    <Type>B</Type>
                    <Value>15</Value>
               </Modifier>
               <Modifier id_ref="A3">
                    <Type>B<Type>
                    <Value>12</Value>
               </Modifier>        
           <Modifiers>
       </Book>
        <Book id_ref="A4">
           <Name>Ruby</Name>
           <Type>Plastic</Type>
           <Modifiers>        
               <Modifier id_ref="A5">
                    <Type>C</Type>
                    <Value>14</Value>
               </Modifier>
               <Modifier id_ref="A6">
                    <Type>B<Type>
                    <Value>18</Value>
               </Modifier>        
           <Modifiers>
       </Book>
  </Books>
</Catalog>

Thank you in advance.

sentana


If you can, I'd recommend not storing the data in XML; instead:

  1. map out its meaning to tables
  2. parse the XML when importing
  3. store in a normalized table
  4. and edit normally.
  5. When needed, you'll generate using the standard XML buildings in rails.

If you do that, you'll have a much better experience in rails.

If you can't, because you don't know the schema, then look at nokogiri

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号