cxxtools::xml::StartElement Class Reference

A start element (Node) which represents an opening tag of an XML document. More...

#include <cxxtools/xml/startelement.h>

Inheritance diagram for cxxtools::xml::StartElement:
cxxtools::xml::Node

Public Member Functions

 StartElement ()
 Constructs a new StartElement object with no name and an empty attribute list.
 StartElement (const String &name)
 Constructs a new StartElement object with the given string as tag name.
StartElementclone () const
 Clones this StartElement object by creating a duplicate on the heap and returning it.
void clear ()
Stringname ()
 Returns the tag name of the opening tag for which this StartElement object was created.
const Stringname () const
 Returns the tag name of the opening tag for which this StartElement object was created.
void setName (const String &name)
 Sets the tag name of the end start for which this StartElement object was created.
void addAttribute (const Attribute &attribute)
 Add the given attribute to the attribute list of this start tag.
const std::list< Attribute > & attributes () const
 Returns the attribute list of this StartElement which contains all attributes of the tag.
const Stringattribute (const String &attributeName) const
 Returns the value of the attribute with the given name.
bool hasAttribute (const String &attributeName) const
const NamespaceContextnamespaceContext () const
 Returns the namespace conText of this StartElement.
void setNamespaceContext (const NamespaceContext &conText)
 Sets the namespace conText for this StartElement.
const StringnamespaceUri (const String &prefix) const
 Returns the namespace uri for the given tag prefix in this StartElments namespace conText.
virtual bool operator== (const Node &node) const
 Compares this StartElement object with the given node.
- Public Member Functions inherited from cxxtools::xml::Node
 Node (Type type)
 Constructs a new Node object with the specified node type.
virtual ~Node ()
 Empty destructor.
Type type () const
 Returns the type of this Node that can be used to determine what specific Node this object is.

Additional Inherited Members

- Public Types inherited from cxxtools::xml::Node
enum  Type {
  Unknown = 0, StartDocument = 1, DocType = 2, EndDocument = 3,
  StartElement = 4, EndElement = 5, Characters = 6, Comment,
  ProcessingInstruction
}

Detailed Description

A start element (Node) which represents an opening tag of an XML document.

A start element is created when the parser reaches a start tag, for example $<a>$. A StartElement object not only stores the name of the tag and its namespace information, but also stores the attributes of the tag. These attributes can be accessed by calling attributes(), attribute() and hasAttribute().

Use name() to get the name of the tag which was closed.

When parsing $test$ a StartElement, a Character and finally an EndElement node is created. If an empty tag is parsed, like for example $$, a StartElement and an EndElement is created.

See Also
EndElement
Node
Attribute

Constructor & Destructor Documentation

cxxtools::xml::StartElement::StartElement ( )
inline

Constructs a new StartElement object with no name and an empty attribute list.

cxxtools::xml::StartElement::StartElement ( const String name)
inline

Constructs a new StartElement object with the given string as tag name.

Parameters
nameThe name of the EndElement object. This is an optional parameter. Default is an empty string.

Member Function Documentation

void cxxtools::xml::StartElement::addAttribute ( const Attribute attribute)
inline

Add the given attribute to the attribute list of this start tag.

This StartElement object holds a list of attributes, which consist of the attribute name and the attribute value. The attributes can be read using attributes() or attribute().

Parameters
attributeThe attribute which is added to this object's attribute list.
const String& cxxtools::xml::StartElement::attribute ( const String attributeName) const

Returns the value of the attribute with the given name.

This StartElement object holds a list of attributes, which consist of the attribute name and the attribute value. This methods returns the value of a single attribute. To access all attributes of this StartElement the method attributes() can be used.

If no attribute with the given name exists, an empty string is returned.

Parameters
attributeNameThe value of the attribute with this name is returned.
Returns
The value of the request attribute; or an empty string if there is no attribute with this name.
const std::list<Attribute>& cxxtools::xml::StartElement::attributes ( ) const
inline

Returns the attribute list of this StartElement which contains all attributes of the tag.

This StartElement object holds a list of attributes, which consist of the attribute name and the attribute value. This method returns all attributes of the represented tag. The list can be iterated using a iterator. To access a specific attribute the method attribute() can be used.

Returns
A list containing all attributes of the tag this StartElement represents.
void cxxtools::xml::StartElement::clear ( )
inline
StartElement* cxxtools::xml::StartElement::clone ( ) const
inlinevirtual

Clones this StartElement object by creating a duplicate on the heap and returning it.

Returns
A cloned version of this StartElement object.

Implements cxxtools::xml::Node.

bool cxxtools::xml::StartElement::hasAttribute ( const String attributeName) const
Returns
Checks if the StartElement has an attribute with the given name.

This method returns $true$ if an attribute with the given name exists in this StartElement. If no attribute with this name exist $false$ is returned.

Parameters
attributeNameIt is checked if an attribute with this attribute name exists.
Returns
$true$ if an attribute with this name exists; $false$ otherwise.
String& cxxtools::xml::StartElement::name ( )
inline

Returns the tag name of the opening tag for which this StartElement object was created.

When parsing test a StartElement, a Character and finally an EndElement node is created. The StartElement has the name "a". If an empty tag is parsed, like for example , only a StartElement and an EndElement ("a") is created.

Returns
The tag name of the opening tag for which this StartElement object was created.
const String& cxxtools::xml::StartElement::name ( ) const
inline

Returns the tag name of the opening tag for which this StartElement object was created.

When parsing test a StartElement, a Character and finally an EndElement node is created. The StartElement has the name "a". If an empty tag is parsed, like for example , only a StartElement and an EndElement ("a") is created.

Returns
The tag name of the opening tag for which this StartElement object was created.
const NamespaceContext& cxxtools::xml::StartElement::namespaceContext ( ) const
inline

Returns the namespace conText of this StartElement.

Returns
NamespaceContext The namespace conText of this StartElment.
See Also
NamespaceContext
const String& cxxtools::xml::StartElement::namespaceUri ( const String prefix) const
inline

Returns the namespace uri for the given tag prefix in this StartElments namespace conText.

The namespace uri is determined using the method NamespaceContext::namespaceUri(). If no namespace uri exists for this prefix an empty string is returned.

Parameters
prefixThe prefix for which the namespace uri is returned.
Returns
The namespace uri for the given prefix; or an empty string if no namespace uri exists for this prefix.
virtual bool cxxtools::xml::StartElement::operator== ( const Node node) const
virtual

Compares this StartElement object with the given node.

This method returns $true$ if the given node also is a StartElement object and the content of both StartElement objects is the same. Otherwise it returns $false$.

Parameters
nodeThis Node object is compared to the current StartElement node object.
Returns
$true if this StartElement object is the same as the given node.

Reimplemented from cxxtools::xml::Node.

void cxxtools::xml::StartElement::setName ( const String name)
inline

Sets the tag name of the end start for which this StartElement object was created.

Parameters
nameThe new name for this StartElement object.
void cxxtools::xml::StartElement::setNamespaceContext ( const NamespaceContext conText)
inline

Sets the namespace conText for this StartElement.

Parameters
conTextThe new namespace conText for this StartElment.
See Also
NamespaceContext

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