If you don't want to use xml.hwp's library interface (see above) for some reason, you can also use the plugin's serialization interface. This is easier to use because it only requires a single function call to convert Hollywood tables to XML documents and vice versa but you won't have fine-tuned control over everything as you have when using the library interface.
Access to the xml.hwp's serialization interface is through Hollywood's
DeserializeTable() functions, or, alternatively, through the
functions. By using the serialization interface, you can convert an XML document into a
Hollywood table through just a single function call:
t = DeserializeTable(FileToString("test.xml"), "xml")
The code above will read all nodes and attributes from
test.xml and store them in
the Hollywood table
The way the XML data is stored inside the table depends on the serialization mode you have set using xml.SetSerializeMode(). The XML plugin supports three different serialization modes:
WriteTable()functions. The table can even contain binary data or code like Hollywood functions. See Hollywood serialization for details.
After you have converted an XML file to a Hollywood table, you could then make any modifications you like directly to the Hollywood table. When you're done with all modifications, you can simply convert your Hollywood table back into an XML document in just a single line like this:
StringToFile(SerializeTable(t, "xml"), "test2.xml")
The code above will convert the table
t to an XML document using the xml.hwp plugin
and save the XML document as
As you can see, the serialization interface is very easy to use but doesn't offer as much flexibility as the library interface which gives you fine-tuned control over many XML documents features.