SDX::Formats::XmlStreamReader Class Reference

Class that reads XML from a stream. More...

#include <SDXXMLStreamReader.h>

Inheritance diagram for SDX::Formats::XmlStreamReader:

SDX::Helpers::StreamReader SDX::ResourceReader

List of all members.

Public Types

enum  TrimMode { Lines, LinesAndNewlines }
 Modes regarding the handling of whitespace. More...

Public Member Functions

 XmlStreamReader (std::istream *iStream=0, SDX::ContentHandler *contentHandler=0)
void setInsertTextNodeOnText (bool)
 Whether to insert an empty *TEXT* node when text is encountered.
void setTrimMode (TrimMode)
 How to trim strings in XML.
void setParseMetaTag (bool)
 Set whether to parse the metatag of the document if it has one.

Detailed Description

Class that reads XML from a stream.

An XML is based on tags. Each node has a start and end tag. End tags start with a slash followed by the name of the node it closes:

	<customer name="Bob 'o Reilly">
		<company>The test company</company>
		<address>Foo lane 83</address>
	<customer name="Kent Brockman">
		<company>Another test company</company>
		<address>Bar avenue 57</address>
For that file, the following events will get sent to the ContentHandler:
 		contentHandler->writeAttribute("name", "Bob 'o Reily");
 		contentHandler->writeNode("company", "The test company");
 		contentHandler->writeNode("address", "Foo lane 83");
 		contentHandler->writeAttribute("name", "Kent Brockman");
 		contentHandler->writeNode("company", "Another test company");
 		contentHandler->writeNode("address", "Bar avenue 57");
Notice that for each piece of text inside a node, an unnamed attribute gets written (see ContentHandler::writeNode). If there's a node with two pieces of text with a node in between (for ex. line1<br />line2) an unnamed attribute gets written then the node gets opened and closed and then another unnamed attribute gets written. If you want a metatag to be sent to you (<?xml version="1.0" encoding="utf-8"?>), check out the setParseMetaTag() function. If you want to know where exactly texts and children are located, see the setInsertTextNodeOnText() method. Notice that the root node is ignored since this is something that's specific to XML. Another thing to note is that named attributes can be seperated by newlines, but the values of named attributes cannot contain newlines.

Definition at line 46 of file SDXXMLStreamReader.h.

Member Enumeration Documentation

Modes regarding the handling of whitespace.

Lines  Trims whitespace surrounding each line.
LinesAndNewlines  Merges all lines into one.

Definition at line 51 of file SDXXMLStreamReader.h.

Member Function Documentation

void XmlStreamReader::setInsertTextNodeOnText ( bool  v  ) 

Whether to insert an empty *TEXT* node when text is encountered.

An example of when you'd want this is when reading HTML. This defaults to false.

Definition at line 20 of file SDXXMLStreamReader.cpp.

void XmlStreamReader::setParseMetaTag ( bool  v  ) 

Set whether to parse the metatag of the document if it has one.

This defaults to false. When a metatag is encountered and this is set to true, a node named *XML_METADATA* is with the given attributes is sent to the given ContentHandler.

Definition at line 28 of file SDXXMLStreamReader.cpp.

void XmlStreamReader::setTrimMode ( TrimMode  trimMode  ) 

How to trim strings in XML.

This defaults to Lines.

Definition at line 24 of file SDXXMLStreamReader.cpp.

The documentation for this class was generated from the following files:

Generated on Mon Apr 27 16:55:50 2009 for SDX by  doxygen 1.5.8