Cyclone 3DR Script
from Technodigit, part of Hexagon. Copyright 1997-2021.
SXmlReader Class Reference

Class to read xml files Sample on how to use this class. More...

Inheritance diagram for SXmlReader:
SObject

Public Types

enum  ErrorEnum { NoError , NotWellFormedError , PrematureEndOfDocumentError , UnexpectedElementError }
 
enum  TokenTypeEnum {
  NoToken , Invalid , StartDocument , EndDocument ,
  StartElement , EndElement , Characters , Comment ,
  DTD , EntityReference , ProcessingInstruction
}
 

Public Slots

Boolean AtEnd ()
 Returns true if the reader has read until the end of the XML document, or if an Error() has occurred and reading has been aborted. Otherwise, it returns false. More...
 
Array Attributes ()
 Returns the attributes of a StartElement. More...
 
String DocumentEncoding ()
 If the TokenType() is StartDocument, this function returns the encoding string as specified in the XML declaration. Otherwise an empty string is returned. More...
 
String DocumentVersion ()
 If the TokenType() is StartDocument, this function returns the version string as specified in the XML declaration. Otherwise an empty string is returned. More...
 
ErrorEnum Error ()
 Returns the type of the current error, or NoError if no error occurred. More...
 
Boolean HasError ()
 Returns true if an error has occurred, otherwise false. More...
 
Boolean IsStandaloneDocument ()
 Returns true if this document has been declared standalone in the XML declaration; otherwise returns false. If no XML declaration has been parsed, this function returns false. More...
 
Boolean IsWhitespace ()
 Returns true if the reader reports characters that only consist of white-space; otherwise returns false. racist function (I'm Charlie) More...
 
qint64 LineNumber ()
 Returns the current line number, starting with 1. More...
 
String Name ()
 Returns the local name of a StartElement, EndElement, or an EntityReference. More...
 
String NamespaceUri ()
 Returns the namespaceUri of a StartElement or EndElement. More...
 
static SXmlReader New ()
 Default constructor to instantiate a XmlReader. More...
 
TokenTypeEnum ReadNext ()
 Reads the next token and returns its type. More...
 
 SetFile (SFile File)
 Sets the current file to device. Setting the device resets reader. More...
 
 SkipCurrentElement ()
 Reads until the end of the current element, skipping any child nodes. This function is useful for skipping unknown elements. The current element is the element matching the most recently parsed start element of which a matching end element has not yet been reached. When the parser has reached the end element, the current element becomes the parent element. More...
 
String Text ()
 Returns the text of Characters, Comment, DTD, or EntityReference. More...
 
String TokenString ()
 Returns the reader's current token as string. More...
 
TokenTypeEnum TokenType ()
 Returns the type of the current token. More...
 
String toString ()
 Get the type of the variable. More...
 
static String toString ()
 Get the type of the variable. More...
 
- Public Slots inherited from SObject
 Clear ()
 To deallocate memory of the object. More...
 
String toString ()
 Get the type of the variable. More...
 

Detailed Description

Class to read xml files Sample on how to use this class.

var fileName = new String(...);
var xmlReader = SXmlReader.New();
var file = SFile.New(fileName);
// Open XML file to read
if ( !file.Open(SFile.ReadOnly) )
throw new Error( 'Failed to read file.' );
xmlReader.SetFile(file);
while (!xmlReader.AtEnd()) {
var type = xmlReader.ReadNext();
continue;
if (type == SXmlReader.StartElement)
{
var attributes = xmlReader.Attributes();
for (var idx = 0; idx < attributes.length; idx++)
print(attributes[idx].Name + ", " + attributes[idx].Value);
continue;
}
}
if (xmlReader.HasError()) {
print("Error");
}
file.Close();
The Sfile class provides an interface for reading from and writing to files.
Definition: SFile.h:20
@ ReadOnly
Definition: SFile.h:31
static SFile New(String name)
Constructs a new file object to represent the file with the given name.
Class to read xml files Sample on how to use this class.
Definition: SXmlReader.h:54
String Name()
Returns the local name of a StartElement, EndElement, or an EntityReference.
static SXmlReader New()
Default constructor to instantiate a XmlReader.
@ StartElement
Definition: SXmlReader.h:78
@ StartDocument
Definition: SXmlReader.h:74
ErrorEnum Error()
Returns the type of the current error, or NoError if no error occurred.

Member Enumeration Documentation

◆ ErrorEnum

Enumerator
NoError 
NotWellFormedError 
PrematureEndOfDocumentError 
UnexpectedElementError 

◆ TokenTypeEnum

Enumerator
NoToken 
Invalid 
StartDocument 
EndDocument 
StartElement 
EndElement 
Characters 
Comment 
DTD 
EntityReference 
ProcessingInstruction 

Member Function Documentation

◆ AtEnd

Boolean SXmlReader::AtEnd ( )
slot

Returns true if the reader has read until the end of the XML document, or if an Error() has occurred and reading has been aborted. Otherwise, it returns false.

◆ Attributes

Array SXmlReader::Attributes ( )
slot

Returns the attributes of a StartElement.

◆ DocumentEncoding

String SXmlReader::DocumentEncoding ( )
slot

If the TokenType() is StartDocument, this function returns the encoding string as specified in the XML declaration. Otherwise an empty string is returned.

◆ DocumentVersion

String SXmlReader::DocumentVersion ( )
slot

If the TokenType() is StartDocument, this function returns the version string as specified in the XML declaration. Otherwise an empty string is returned.

◆ Error

ErrorEnum SXmlReader::Error ( )
slot

Returns the type of the current error, or NoError if no error occurred.

◆ HasError

Boolean SXmlReader::HasError ( )
slot

Returns true if an error has occurred, otherwise false.

◆ IsStandaloneDocument

Boolean SXmlReader::IsStandaloneDocument ( )
slot

Returns true if this document has been declared standalone in the XML declaration; otherwise returns false. If no XML declaration has been parsed, this function returns false.

◆ IsWhitespace

Boolean SXmlReader::IsWhitespace ( )
slot

Returns true if the reader reports characters that only consist of white-space; otherwise returns false. racist function (I'm Charlie)

◆ LineNumber

qint64 SXmlReader::LineNumber ( )
slot

Returns the current line number, starting with 1.

◆ Name

String SXmlReader::Name ( )
slot

Returns the local name of a StartElement, EndElement, or an EntityReference.

◆ NamespaceUri

String SXmlReader::NamespaceUri ( )
slot

Returns the namespaceUri of a StartElement or EndElement.

◆ New

static SXmlReader SXmlReader::New ( )
staticslot

Default constructor to instantiate a XmlReader.

◆ ReadNext

TokenTypeEnum SXmlReader::ReadNext ( )
slot

Reads the next token and returns its type.

◆ SetFile

SXmlReader::SetFile ( SFile  File)
slot

Sets the current file to device. Setting the device resets reader.

◆ SkipCurrentElement

SXmlReader::SkipCurrentElement ( )
slot

Reads until the end of the current element, skipping any child nodes. This function is useful for skipping unknown elements. The current element is the element matching the most recently parsed start element of which a matching end element has not yet been reached. When the parser has reached the end element, the current element becomes the parent element.

◆ Text

String SXmlReader::Text ( )
slot

Returns the text of Characters, Comment, DTD, or EntityReference.

◆ TokenString

String SXmlReader::TokenString ( )
slot

Returns the reader's current token as string.

◆ TokenType

TokenTypeEnum SXmlReader::TokenType ( )
slot

Returns the type of the current token.

◆ toString [1/2]

String SXmlReader::toString ( )
slot

Get the type of the variable.

◆ toString [2/2]

static String SXmlReader::toString ( )
staticslot

Get the type of the variable.