North State Framework in C#  V3.0.0
An object-oriented framework for implementing UML state machines.
Public Types | Public Member Functions | List of all members
NSFXMLDocument Class Reference

Represents a simple in-memory xml document editor. More...

Public Types

enum  ErrorStatus {
  NoError, EmptyDocument, EmptyElement, ParseError,
  FileError, BadValue
}
 Represents xml document error status. More...
 

Public Member Functions

 NSFXMLDocument ()
 Creates an xml document. More...
 
 NSFXMLDocument (NSFString rootTag)
 Creates an xml document. More...
 
 NSFXMLDocument (NSFXMLDocument copyDocument)
 Creates an xml document. More...
 
void addChildElementBack (NSFString childTag)
 Adds an element to the back of the current element's child elements More...
 
void addChildElementBack (NSFString childTag, NSFString childText)
 Adds an element to the back of the current element's child elements More...
 
void addChildElementBack< ValueType > (NSFString childTag, ValueType value)
 Adds an element to the back of the current element's child elements More...
 
bool addChildElementBack (NSFXMLDocument document)
 Adds an xml document to the back of the current element's child elements More...
 
bool addChildElementBack (NSFXMLElement childElement)
 Adds an element to the back of the current element's child elements More...
 
void addChildElementFront (NSFString childTag)
 Adds an element to the front of the current element's child elements More...
 
void addChildElementFront (NSFString childTag, NSFString childText)
 Adds an element to the front of the current element's child elements More...
 
void addChildElementFront< ValueType > (NSFString childTag, ValueType value)
 Adds an element to the front of the current element's child elements More...
 
bool addChildElementFront (NSFXMLDocument document)
 Adds an xml document to the front of the current element's child elements More...
 
bool addChildElementFront (NSFXMLElement childElement)
 Adds an element to the front of the current element's child elements More...
 
void addRootElement (NSFString rootTag)
 Adds a root element and sets the current element and bookmark element to the root element. More...
 
bool atBookmarkElement ()
 Checks if at the bookmark element. More...
 
bool atRootElement ()
 Checks if at the root element. More...
 
bool containsChildElement ()
 Checks if the current elements contains a child element. More...
 
bool containsChildElement (NSFString childTag)
 Checks if the current elements contains a child element with the specified tag. More...
 
bool deleteChildElementBack ()
 Deletes the current element's last child element. More...
 
bool deleteChildElementFront ()
 Deletes the current element's first child element. More...
 
bool deleteCurrentElement ()
 Deletes the current element. More...
 
bool getChildElementBoolean (NSFString childTag, ref bool value)
 Gets the boolean value of the child element with the specified tag. More...
 
void getChildElementBoolean (NSFString childTag, ref bool value, bool defaultValue)
 Gets the boolean value of the child element with the specified tag or the default value if no child found. More...
 
bool getChildElementText (NSFString childTag, NSFString text)
 Gets the text of the child element with the specified tag. More...
 
void getChildElementText (NSFString childTag, NSFString text, NSFString defaultText)
 Gets the text of the child element with the specified tag or the default text if no child found. More...
 
bool getChildElementValue< ValueType > (NSFString childTag, ref ValueType value)
 Gets the numeric value of the child element with the specified tag. More...
 
void getChildElementValue< ValueType > (NSFString childTag, ref ValueType value, ValueType defaultValue)
 Gets the numeric value of the child element with the specified tag or the default value if no child found. More...
 
bool getCurrentElementBoolean (ref bool value)
 Gets the current element's boolean value. More...
 
bool getCurrentElementTag (NSFString tag)
 Gets the current element's tag. More...
 
bool getCurrentElementText (NSFString text)
 Gets the current element's text. More...
 
bool getCurrentElementValue< ValueType > (ref ValueType value)
 Gets the current element's numeric value. More...
 
ErrorStatus getErrorStatus ()
 Gets the error status of the last operation. More...
 
bool getNumberOfChildElements (out int numberOfChildElements)
 Gets the number of child elements. More...
 
bool jumpToBookmarkElement ()
 Moves the current element pointer to the bookmarked element. More...
 
bool jumpToChildElement (NSFString childTag)
 Moves the current element pointer to the first child element with the specified tag. More...
 
bool jumpToChildElementBack ()
 Moves the current element pointer to the last child element of the current element. More...
 
bool jumpToChildElementFront ()
 Moves the current element pointer to the first child element of the current element. More...
 
bool jumpToNextElement ()
 Moves the current element pointer to the next element at the same level. More...
 
bool jumpToNextElement (NSFString nextTag)
 Moves the current element pointer to the next element with the specified tag at the same level. More...
 
bool jumpToParentElement ()
 Moves the current element pointer to the parent of the current element. More...
 
bool jumpToParentElement (NSFString parentTag)
 Moves the current element pointer to the parent of the current element with the specified tag. More...
 
bool jumpToRootElement ()
 Moves the current element pointer to the root element. More...
 
bool loadBuffer (NSFString buffer)
 Populates the document with xml formatted text in the specified buffer. More...
 
void loadDocument (NSFXMLDocument copyDocument)
 Populates the document with xml from specified xml document. More...
 
bool loadFile (NSFString fileName)
 Populates the document with xml formatted text in the specified file. More...
 
void reset ()
 Sets the current and bookmark element to the root element. More...
 
bool save (NSFString fileName)
 Saves the xml document to the specified file name. More...
 
void setBookmarkElement ()
 Sets the bookmark element to the current element. More...
 
void setChildElementText (NSFString childTag, NSFString text)
 Sets the text of the specified child element or creates a child element if no match is found. More...
 
void setChildElementValue< ValueType > (NSFString childTag, ValueType value)
 Sets the text of the specified child element to the specified numeric value, converted to a string, or creates a child element if no match is found. More...
 
bool setCurrentElementTag (NSFString tag)
 Sets the current element's tag. More...
 
bool setCurrentElementText (NSFString text)
 Sets the current element's text. More...
 
bool setCurrentElementValue< ValueType > (ValueType value)
 Sets the current element's text to the specified value, converted to a string. More...
 

Detailed Description

Represents a simple in-memory xml document editor.

This class is not thread safe.

Member Enumeration Documentation

Represents xml document error status.

Enumerator
NoError 
EmptyDocument 
EmptyElement 
ParseError 
FileError 
BadValue 

Constructor & Destructor Documentation

Creates an xml document.

NSFXMLDocument ( NSFString  rootTag)

Creates an xml document.

Parameters
rootTagThe string for the root element of the document.
NSFXMLDocument ( NSFXMLDocument  copyDocument)

Creates an xml document.

Parameters
copyDocumentThe document to copy.

Member Function Documentation

void addChildElementBack ( NSFString  childTag)

Adds an element to the back of the current element's child elements

Parameters
childTagThe tag for the element.
void addChildElementBack ( NSFString  childTag,
NSFString  childText 
)

Adds an element to the back of the current element's child elements

Parameters
childTagThe tag for the element.
childTextThe text for the element.
bool addChildElementBack ( NSFXMLDocument  document)

Adds an xml document to the back of the current element's child elements

Parameters
documentThe document to add.
Returns
True if successful, false otherwise.
bool addChildElementBack ( NSFXMLElement  childElement)

Adds an element to the back of the current element's child elements

Parameters
childElementThe element to add.
Returns
True if successful, false otherwise.
void addChildElementBack< ValueType > ( NSFString  childTag,
ValueType  value 
)

Adds an element to the back of the current element's child elements

Parameters
childTagThe tag for the element.
valueThe value (converted to string) for the element.
void addChildElementFront ( NSFString  childTag)

Adds an element to the front of the current element's child elements

Parameters
childTagThe tag for the element.
void addChildElementFront ( NSFString  childTag,
NSFString  childText 
)

Adds an element to the front of the current element's child elements

Parameters
childTagThe tag for the element.
childTextThe text for the element.
bool addChildElementFront ( NSFXMLDocument  document)

Adds an xml document to the front of the current element's child elements

Parameters
documentThe document to add.
Returns
True if successful, false otherwise.
bool addChildElementFront ( NSFXMLElement  childElement)

Adds an element to the front of the current element's child elements

Parameters
childElementThe element to add.
Returns
True if successful, false otherwise.
void addChildElementFront< ValueType > ( NSFString  childTag,
ValueType  value 
)

Adds an element to the front of the current element's child elements

Parameters
childTagThe tag for the element.
valueThe value (converted to string) for the element.
void addRootElement ( NSFString  rootTag)

Adds a root element and sets the current element and bookmark element to the root element.

bool atBookmarkElement ( )

Checks if at the bookmark element.

Returns
True if at bookmark element, false otherwise.
bool atRootElement ( )

Checks if at the root element.

Returns
True if at root element, false otherwise.
bool containsChildElement ( )

Checks if the current elements contains a child element.

Returns
True if current element contains a child element, false otherwise.
bool containsChildElement ( NSFString  childTag)

Checks if the current elements contains a child element with the specified tag.

Parameters
childTagThe tag for the child element.
Returns
True if current element contains a child element with the specified tag, false otherwise.
bool deleteChildElementBack ( )

Deletes the current element's last child element.

Returns
True if successful, false otherwise.
bool deleteChildElementFront ( )

Deletes the current element's first child element.

Returns
True if successful, false otherwise.
bool deleteCurrentElement ( )

Deletes the current element.

Returns
True if successful, false otherwise.
bool getChildElementBoolean ( NSFString  childTag,
ref bool  value 
)

Gets the boolean value of the child element with the specified tag.

Parameters
childTagThe child element's tag.
valueThe child element's boolean value.
Returns
True if successful, false otherwise.

This operation looks for (case insensitive): "true", "t", or "1" for true; "false", "f", or "0" for false.

void getChildElementBoolean ( NSFString  childTag,
ref bool  value,
bool  defaultValue 
)

Gets the boolean value of the child element with the specified tag or the default value if no child found.

Parameters
childTagThe child element's tag.
valueThe child element's boolean value.
defaultValueThe default value returned in value argument if child not found.

This operation looks for (case insensitive): "true", "t", or "1" for true; "false", "f", or "0" for false.

bool getChildElementText ( NSFString  childTag,
NSFString  text 
)

Gets the text of the child element with the specified tag.

Parameters
childTagThe child element's tag.
textThe child element's text.
Returns
True if successful, false otherwise.
void getChildElementText ( NSFString  childTag,
NSFString  text,
NSFString  defaultText 
)

Gets the text of the child element with the specified tag or the default text if no child found.

Parameters
childTagThe child element's tag.
textThe child element's text.
defaultTextThe default text returned in text argument if child not found.
bool getChildElementValue< ValueType > ( NSFString  childTag,
ref ValueType  value 
)

Gets the numeric value of the child element with the specified tag.

Parameters
childTagThe child element's tag.
valueThe child element's value.
Returns
True if successful, false otherwise.
Type Constraints
ValueType :IConvertible 
void getChildElementValue< ValueType > ( NSFString  childTag,
ref ValueType  value,
ValueType  defaultValue 
)

Gets the numeric value of the child element with the specified tag or the default value if no child found.

Parameters
childTagThe child element's tag.
valueThe child element's value.
defaultValueThe default value returned in value argument if child not found.
Type Constraints
ValueType :IConvertible 
bool getCurrentElementBoolean ( ref bool  value)

Gets the current element's boolean value.

Parameters
valueThe current element's boolean value.
Returns
True if successful, false otherwise.

This operation looks for (case insensitive): "true", "t", or "1" for true; "false", "f", or "0" for false.

bool getCurrentElementTag ( NSFString  tag)

Gets the current element's tag.

Parameters
tagThe current element's tag.
Returns
True if successful, false otherwise.
bool getCurrentElementText ( NSFString  text)

Gets the current element's text.

Parameters
textThe current element's text.
Returns
True if successful, false otherwise.
bool getCurrentElementValue< ValueType > ( ref ValueType  value)

Gets the current element's numeric value.

Parameters
valueThe current element's value.
Returns
True if successful, false otherwise.
Type Constraints
ValueType :IConvertible 
ErrorStatus getErrorStatus ( )

Gets the error status of the last operation.

Boolean methods that return false set the error status of the document.

bool getNumberOfChildElements ( out int  numberOfChildElements)

Gets the number of child elements.

Parameters
numberOfChildElementsThe number of child elements.
Returns
True if successful, false otherwise.
bool jumpToBookmarkElement ( )

Moves the current element pointer to the bookmarked element.

Returns
True if successful, false otherwise.

The bookmark provides a mechanism for jumping back to a specific element in the document.

bool jumpToChildElement ( NSFString  childTag)

Moves the current element pointer to the first child element with the specified tag.

Parameters
childTagThe child tag to find.
Returns
True if successful, false otherwise.
bool jumpToChildElementBack ( )

Moves the current element pointer to the last child element of the current element.

Returns
True if successful, false otherwise.
bool jumpToChildElementFront ( )

Moves the current element pointer to the first child element of the current element.

Returns
True if successful, false otherwise.
bool jumpToNextElement ( )

Moves the current element pointer to the next element at the same level.

Returns
True if successful, false otherwise.
bool jumpToNextElement ( NSFString  nextTag)

Moves the current element pointer to the next element with the specified tag at the same level.

Parameters
nextTagThe tag to find.
Returns
True if successful, false otherwise.
bool jumpToParentElement ( )

Moves the current element pointer to the parent of the current element.

Returns
True if successful, false otherwise.
bool jumpToParentElement ( NSFString  parentTag)

Moves the current element pointer to the parent of the current element with the specified tag.

Parameters
parentTagThe tag to find.
Returns
True if successful, false otherwise.
bool jumpToRootElement ( )

Moves the current element pointer to the root element.

Returns
True if successful, false otherwise.
bool loadBuffer ( NSFString  buffer)

Populates the document with xml formatted text in the specified buffer.

Parameters
bufferThe buffer to load.
Returns
True if successful, false otherwise.
void loadDocument ( NSFXMLDocument  copyDocument)

Populates the document with xml from specified xml document.

Parameters
copyDocumentThe file to copy.
bool loadFile ( NSFString  fileName)

Populates the document with xml formatted text in the specified file.

Parameters
fileNameThe file to load.
Returns
True if successful, false otherwise.
void reset ( )

Sets the current and bookmark element to the root element.

bool save ( NSFString  fileName)

Saves the xml document to the specified file name.

Parameters
fileNameThe name of the file.
Returns
True if successful, false otherwise.
void setBookmarkElement ( )

Sets the bookmark element to the current element.

The bookmark provides a mechanism for jumping back to a specific element in the document.

void setChildElementText ( NSFString  childTag,
NSFString  text 
)

Sets the text of the specified child element or creates a child element if no match is found.

Parameters
childTagThe child element's tag.
textThe child element's text.
void setChildElementValue< ValueType > ( NSFString  childTag,
ValueType  value 
)

Sets the text of the specified child element to the specified numeric value, converted to a string, or creates a child element if no match is found.

Parameters
childTagThe child element's tag.
valueThe child element's value.
Type Constraints
ValueType :IConvertible 
bool setCurrentElementTag ( NSFString  tag)

Sets the current element's tag.

Parameters
tagThe current element's tag.
Returns
True if successful, false otherwise.
bool setCurrentElementText ( NSFString  text)

Sets the current element's text.

Parameters
textThe current element's text.
Returns
True if successful, false otherwise.
bool setCurrentElementValue< ValueType > ( ValueType  value)

Sets the current element's text to the specified value, converted to a string.

Parameters
valueThe current element's value.
Returns
True if successful, false otherwise.



Copyright 2004-2014, North State Software, LLC. All rights reserved.