How Do I Save an XML document?
In This Topic
Problem
An XML document can be exported into a string, a file, or as binary data. Each generated object will contain the following methods that allow XML data to be exported. The specifics of this varies depending up the language your using, but the basics methods are described below.
Function |
Description |
ToXml |
Saves an XML document to a string (See unicode notes) |
ToXmlFile |
Saves an XML document to a file |
ToXmlStream |
Saves an XML document as binary data |
Example
Person person = new Person(); ... String strXML = person.toXml(); person.toXmlFile("MyExample.xml"); byte[] data = person.toXmlStream();
<?xml version="1.0" encoding="UTF-8"?> <Person> <name>Joe Blogs</name> <Address> <HouseNumber>15</HouseNumber> <PostCode>LS5 9PQ</PostCode> </Address> </Person>
Function Reference
C++ |
|
Function |
Description |
ToXml |
Exports the object as an XML document to a string.
This method will only export XML.
Options allow you to change set whether the XML is formatted (indented), which kind of EOL sequence to use, and the language encoding to use. The string produced is always in the current code page (or UNICODE if using a UNICODE build). If you want to use other encoding's (i.e. UTF-8) then use ToXmlStream.
See Unicode Notes
|
ToXmlFile |
Exports the object as an XML document, and writes it to a file Options allow you to change set whether the XML is formatted (indented), which kind of EOL sequence to use, and the language encoding to use. |
ToXmlStream |
Exports the object as an XML document, and places it in a CBinaryData object Options allow you to change set whether the XML is formatted (indented), which kind of EOL sequence to use, and the language encoding to use. |
|
C# |
|
Function |
Description |
ToXml |
Exports the object as an XML document to a string.
This method will only export XML.
Options allow you to change set whether the XML is formatted (indented), which kind of EOL sequence to use, and the language encoding to use. The string produced is always in UNICODE. If you want to use other encoding's (i.e. UTF-8) then use ToXmlStream.
See Unicode Notes
|
ToXmlFile |
Exports the object as an XML document, and writes it to a file Options allow you to change set whether the XML is formatted (indented), which kind of EOL sequence to use, and the language encoding to use. |
ToXmlStream |
Exports the object as an XML document, and places it in a System.IO.Stream object Options allow you to change set whether the XML is formatted (indented), which kind of EOL sequence to use, and the language encoding to use.
|
|
Java |
|
Function |
Description |
toXml |
Exports the object as an XML document to a string.
This method will only export XML.
Options allow you to change set whether the XML is formatted (indented), which kind of EOL sequence to use, and the language encoding to use. The string produced is always in UNICODE. If you want to use other encoding's (i.e. UTF-8) then use ToXmlStream.
See Unicode Notes
|
toXmlFile |
Exports the object as an XML document, and writes it to a file Options allow you to change set whether the XML is formatted (indented), which kind of EOL sequence to use, and the language encoding to use. |
toXmlStream |
Exports the object as an XML document, and places it in a byte[] Options allow you to change set whether the XML is formatted (indented), which kind of EOL sequence to use, and the language encoding to use.
|
|
Visual Basic |
|
Function |
Description |
ToXml |
Exports the object as an XML document to a string.
This method will only export XML.
Options allow you to change set whether the XML is formatted (indented), which kind of EOL sequence to use, and the language encoding to use. The string produced is always in UNICODE. If you want to use other encoding's (i.e. UTF-8) then use ToXmlStream.
See Unicode Notes
|
ToXmlFile |
Exports the object as an XML document, and writes it to a file Options allow you to change set whether the XML is formatted (indented), which kind of EOL sequence to use, and the language encoding to use. |
ToXmlStream |
Exports the object as an XML document, and places it in a Variant as a byte array Options allow you to change set whether the XML is formatted (indented), which kind of EOL sequence to use, and the language encoding to use.
|
|
Notes
Description |
Value |
Article Created |
7/2/2006 |
Applies to |
Liquid XML 2005 (4.1) and greater |
Also See |
Unicode Notes |