com.esri.arcgis.system
Class XMLReader

java.lang.Object
  extended by com.esri.arcgis.system.XMLReader
All Implemented Interfaces:
com.esri.arcgis.interop.RemoteObjRef, ISupportErrorInfo, IXMLReader, Serializable

public class XMLReader
extends Object
implements com.esri.arcgis.interop.RemoteObjRef, IXMLReader, ISupportErrorInfo

An XML sequential document reader.

Remarks

Use the XMLReader coclass when you wish to provide access to members that control the sequential reading of XML. XMLStream needs to be hooked-up in order to read the stream.

'*** Create an XML stream and read into it from an XML file

Dim pXMLStream As IXMLStream
Set pXMLStream = New XmlStream

pXMLStream.LoadFromFile "d:\temp\foo.xml"

'*** Create a reader object and point it to the stream

Dim pXMLReader As IXMLReader
Set pXMLReader = New XMLReader

pXMLReader.ReadFrom pXMLStream

'*** Create an XML serializer and use it to deserialize the recordset object from
'*** the stream using the XMLReader

Dim pxmlserial As IXMLSerializer
Dim pRecordSet As IRecordSet

Set pxmlserial = New XMLSerializer
Set pRecordSet = pxmlserial.ReadObject(pXMLReader, Nothing, Nothing)

See the IXMLReader interface for more on getting information about reading of objects.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

See Also:
IXMLStream, IXMLWriter, IXMLReader, IXMLSerialize, Serialized Form

Constructor Summary
XMLReader()
          Constructs a XMLReader using ArcGIS Engine.
XMLReader(Object obj)
          Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
XMLReader theXMLReader = (XMLReader) obj;
 
Method Summary
 void closeElement()
          Moves position to parent element.
 boolean equals(Object o)
          Compare this object with another
 IXMLAttributes getAttributes()
          Attributes of current element.
static String getClsid()
          getClsid.
 String getLocalName()
          Local name of current element.
 IXMLNamespaces getNamespaceDeclarations()
          Namespace declarations of current element.
 String getNamespacePrefix()
          Namespace prefix of current element.
 String getNamespaceURI()
          Namespace URI of current element.
 String getText()
          Text value of current element.
 int hashCode()
          the hashcode for this object
 void interfaceSupportsErrorInfo(GUID riid)
          interfaceSupportsErrorInfo
 boolean isHasElementChildren()
          Indicates whether the current element has child elements.
 boolean isLastChild()
          Indicates whether the current element is the last child element of its parent.
 String lookupPrefix(String prefix)
          Obtains the prefix for a declared URI.
 void nextElement()
          Moves position to next element.
 void openElement()
          Moves position to first child element.
 byte[] readBinary()
          Reads the current element value as a binary array.
 boolean readBoolean()
          Reads the current element value as a boolean.
 byte readByte()
          Reads the current element value as a byte.
 Date readDate()
          Reads the current element value as a date.
 double readDouble()
          Reads the current element value as a double.
 float readFloat()
          Reads the current element value as a float.
 void readFrom(IStream inputStream)
          Specifies the input XML stream.
 int readInteger()
          Reads the current element value as a long.
 short readShort()
          Reads the current element value as a short.
 Object readVariant()
          Reads the current element value as a variant.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.esri.arcgis.interop.RemoteObjRef
getJintegraDispatch, release
 

Constructor Detail

XMLReader

public XMLReader()
          throws IOException,
                 UnknownHostException
Constructs a XMLReader using ArcGIS Engine.

Throws:
IOException - if there are interop problems
UnknownHostException - if there are interop problems

XMLReader

public XMLReader(Object obj)
          throws IOException
Deprecated. As of ArcGIS 9.2, replaced by normal Java casts.
XMLReader theXMLReader = (XMLReader) obj;

Construct a XMLReader using a reference to such an object returned from ArcGIS Engine or Server. This is semantically equivalent to casting obj to XMLReader.

Parameters:
obj - an object returned from ArcGIS Engine or Server
Throws:
IOException - if there are interop problems
Method Detail

getClsid

public static String getClsid()
getClsid.


equals

public boolean equals(Object o)
Compare this object with another

Overrides:
equals in class Object

hashCode

public int hashCode()
the hashcode for this object

Overrides:
hashCode in class Object

readFrom

public void readFrom(IStream inputStream)
              throws IOException,
                     AutomationException
Specifies the input XML stream.

Remarks

The ReadFrom method specifies the input XML stream.

For example:

Dim pXmlReader As IXMLReader
Set pXmlReader = New XMLReader


Dim pXmlStream as IXMLStream
Set pXmlStream = new XMLStream


pXmlStream.OpenFromFile App.Path & "\file.xml"
pXmlReader.ReadFrom pXmlStream


If xml file is empty the XMLStream will evoke Automation error. Xml file needs to be of a proper structure.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
readFrom in interface IXMLReader
Parameters:
inputStream - A reference to a com.esri.arcgis.system.IStream (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getLocalName

public String getLocalName()
                    throws IOException,
                           AutomationException
Local name of current element.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
getLocalName in interface IXMLReader
Returns:
The localName
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getNamespaceURI

public String getNamespaceURI()
                       throws IOException,
                              AutomationException
Namespace URI of current element.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
getNamespaceURI in interface IXMLReader
Returns:
The uri
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getNamespacePrefix

public String getNamespacePrefix()
                          throws IOException,
                                 AutomationException
Namespace prefix of current element.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
getNamespacePrefix in interface IXMLReader
Returns:
The prefix
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getNamespaceDeclarations

public IXMLNamespaces getNamespaceDeclarations()
                                        throws IOException,
                                               AutomationException
Namespace declarations of current element.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
getNamespaceDeclarations in interface IXMLReader
Returns:
A reference to a com.esri.arcgis.system.IXMLNamespaces
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getAttributes

public IXMLAttributes getAttributes()
                             throws IOException,
                                    AutomationException
Attributes of current element.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
getAttributes in interface IXMLReader
Returns:
A reference to a com.esri.arcgis.system.IXMLAttributes
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getText

public String getText()
               throws IOException,
                      AutomationException
Text value of current element.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
getText in interface IXMLReader
Returns:
The text
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

isHasElementChildren

public boolean isHasElementChildren()
                             throws IOException,
                                    AutomationException
Indicates whether the current element has child elements.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
isHasElementChildren in interface IXMLReader
Returns:
The hasChildren
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

isLastChild

public boolean isLastChild()
                    throws IOException,
                           AutomationException
Indicates whether the current element is the last child element of its parent.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
isLastChild in interface IXMLReader
Returns:
The isLast
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

nextElement

public void nextElement()
                 throws IOException,
                        AutomationException
Moves position to next element.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
nextElement in interface IXMLReader
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

openElement

public void openElement()
                 throws IOException,
                        AutomationException
Moves position to first child element.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
openElement in interface IXMLReader
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

closeElement

public void closeElement()
                  throws IOException,
                         AutomationException
Moves position to parent element.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
closeElement in interface IXMLReader
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

lookupPrefix

public String lookupPrefix(String prefix)
                    throws IOException,
                           AutomationException
Obtains the prefix for a declared URI.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
lookupPrefix in interface IXMLReader
Parameters:
prefix - The prefix (in)
Returns:
The uri
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

readBoolean

public boolean readBoolean()
                    throws IOException,
                           AutomationException
Reads the current element value as a boolean.

Remarks

The ReadBoolean method specifies the current element value as a boolean.

Element value 1 or true will return boolean value of true, anything else will return false.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
readBoolean in interface IXMLReader
Returns:
The value
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

readByte

public byte readByte()
              throws IOException,
                     AutomationException
Reads the current element value as a byte.

Description

Remarks

The ReadByte method specifies the current element value as a byte.

Byte variables are stored as single, unsigned 8 bit numbers (1 byte), its range is from 0 to 255. Anything below and above these numbers will cause the Invalid Procedure Call Error.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
readByte in interface IXMLReader
Returns:
An unsigned byte
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

readShort

public short readShort()
                throws IOException,
                       AutomationException
Reads the current element value as a short.

Remarks

The ReadShort method specifies the current element value as a short.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
readShort in interface IXMLReader
Returns:
The value
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

readInteger

public int readInteger()
                throws IOException,
                       AutomationException
Reads the current element value as a long.

Remarks

The ReadInteger method specifies the current element value as a Integer.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
readInteger in interface IXMLReader
Returns:
The value
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

readFloat

public float readFloat()
                throws IOException,
                       AutomationException
Reads the current element value as a float.

Remarks

The ReadFloat method specifies the current element value as a float.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
readFloat in interface IXMLReader
Returns:
The value
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

readDouble

public double readDouble()
                  throws IOException,
                         AutomationException
Reads the current element value as a double.

Remarks

The ReadDouble method specifies the current element value as a double.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
readDouble in interface IXMLReader
Returns:
The value
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

readDate

public Date readDate()
              throws IOException,
                     AutomationException
Reads the current element value as a date.

Remarks

The ReadDate method specifies the current element value as a date.
Date value in xml file should be only of this format:
2005-01-28T12:17:58
otherwise the ReadDate will invoke Invalid Procedure Call Error.

Example of "data.xml" file:

<?xml version="1.0"?>
<Data description="example of ReadDate">
<type>
<date>2005-01-28T12:23:34</date>

</type>

</Data>

VB6 code to get date value:

Dim pXMLStream As IXMLStream
Set pXMLStream = New XMLStream

pXMLStream.LoadFromFile App.Path + "\data.xml"

pXMLReader.OpenElement
pXMLReader.OpenElement

Dim dateValue As Date
dateValue = pXMLReader.ReadDate

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
readDate in interface IXMLReader
Returns:
The value
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

readBinary

public byte[] readBinary()
                  throws IOException,
                         AutomationException
Reads the current element value as a binary array.

Remarks

The ReadBinary method specifies the current element value as a binary array.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
readBinary in interface IXMLReader
Returns:
An unsigned byte
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

readVariant

public Object readVariant()
                   throws IOException,
                          AutomationException
Reads the current element value as a variant.

Remarks

The ReadVariant method specifies the current element value as a variant.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
readVariant in interface IXMLReader
Returns:
A Variant
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

interfaceSupportsErrorInfo

public void interfaceSupportsErrorInfo(GUID riid)
                                throws IOException,
                                       AutomationException
interfaceSupportsErrorInfo

Description

Indicates whether the interface supports IErrorInfo.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Specified by:
interfaceSupportsErrorInfo in interface ISupportErrorInfo
Parameters:
riid - A Structure: com.esri.arcgis.support.ms.stdole.GUID (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.