Edit Xml from web forms
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:
- map out its meaning to tables
- parse the XML when importing
- store in a normalized table
- and edit normally.
- 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
精彩评论