Interface IXMLWriter
- Namespace
- ESRI.ArcGIS.esriSystem
- Assembly
- ESRI.Server.System.dll
Provides access to members that control the sequential writing of XML.
[Guid("5F50E520-1278-4C7A-937C-AE5874548431")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IXMLWriter
Remarks
The IXMLWriter interface provides nineteen methods to use for writing out specific data elements.
Methods
LookupNamespace(string)
Obtains the declared namespace prefix for a namespace.
string LookupNamespace(string uri)
Parameters
uristring
Returns
WriteBinary(ref byte[])
Writes an element value as a binary array.
void WriteBinary(ref byte[] Value)
Parameters
Valuebyte[]
Remarks
The WriteBinary method writes an element value as a binary array.
WriteBoolean(bool)
Writes an element value as a boolean.
void WriteBoolean(bool Value)
Parameters
Valuebool
WriteByte(byte)
Writes an element value as a byte.
void WriteByte(byte Value)
Parameters
Valuebyte
WriteCData(string)
Writes a CDATA section.
void WriteCData(string cdata)
Parameters
cdatastring
Remarks
All text inside XML document is parsed by the XML parser. Only the text inside the CDATA section is ignored by the parser. If your text has lots of "<", ">", "&", "'", and "" (like program code), it could be hidden in CDATA section.
For example,
<test>
<![CDATA[
if a > b & b > c, then a > c
]]>
</test>
In the example above, everything inside CDATA section was ignored by the parser. It would show <test>if a > b & b > c, then a > c</test> in any web browser.
Example of creating such CDATA section using IXMLWriter:
Dim pXMLStream as IXMLStream
Set pXMLStream = new XMLStream
Dim pXMLWriter as IXMLWriter
Set pXMLWriter = new XMLWriter
pXMLWriter.WriteTo pXMLStream
pXMLWriter.WriteCData "if a > b & b > c, then a > c"
WriteDate(DateTime)
Writes an element value as a date.
void WriteDate(DateTime Value)
Parameters
ValueDateTime
WriteDouble(double)
Writes an element value as a double.
void WriteDouble(double Value)
Parameters
Valuedouble
WriteEndTag()
Writes the ending tag of an element.
void WriteEndTag()
WriteFloat(float)
Writes an element value as a float.
void WriteFloat(float Value)
Parameters
Valuefloat
WriteInteger(int)
Writes an element value as a long.
void WriteInteger(int Value)
Parameters
Valueint
WriteNewLine()
Writes a newline.
void WriteNewLine()
WriteShort(short)
Writes an element value as a short.
void WriteShort(short Value)
Parameters
Valueshort
WriteStartTag(string, string, IXMLAttributes, IXMLNamespaces, bool)
Writes the starting tag of an element.
void WriteStartTag(string LocalName, string uri, IXMLAttributes Attributes, IXMLNamespaces namespaces, bool isEmpty)
Parameters
LocalNamestringuristringAttributesIXMLAttributesnamespacesIXMLNamespacesisEmptybool
Remarks
The WriteStartTag method specifies the starting tag of an element.
For example:
<Length>
WriteTab()
Writes a tab.
void WriteTab()
WriteText(string)
Writes the text value of an element.
void WriteText(string Text)
Parameters
Textstring
Remarks
The WriteText method writes the text value of an element.
WriteTo(IStream)
Specifies output XML stream.
void WriteTo(IStream outputStream)
Parameters
outputStreamIStream
Remarks
The WriteTo method specifies the output XML stream. XMLStream lets you write/read (in our case write) xml data to stream object.
For Example:
Dim pWriter As IXMLWriter
Set pWriter = New XMLWriter
Dim pXMLStream as IXMLStream
Set pXMLStream = new XMLStream
'*** This sets output to XML Stream ***
pWriter.WriteTo pStream
'*** Write some xml to the stream ***
pWriter.WriteXMLDeclaration
'*** Save stream to the file ***
pXMLStream.SaveToFile App.Path & "\new.xml"
WriteVariant(object)
Writes an element value as a variant.
void WriteVariant(object Value)
Parameters
Valueobject
Remarks
The WriteVariant method writes an element value as a variant.
WriteXML(string)
Writes raw XML.
void WriteXML(string XML)
Parameters
XMLstring
Remarks
The RawXML method writes XML code to Stream object. The XML code should be well-formed and valid, otherwise the XMLReader will raise error if the Stream is going to be read afterwards.
WriteXMLDeclaration()
Writes the XML document declaration.
void WriteXMLDeclaration()
Remarks
The WriteXMLDeclaration writes
<?xml version="1.0" encoding="utf-8" ?>
to Stream object. XML Declaration should always be included, as it defines the XML version and the encoding of the document.