Webmaster  |  Imprint 
C++ Server Pages
Main  |  License  |  Documentation  |  Download 

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 StartElement:

Node List of all members.

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.
 ~StartElement ()
 Empty destructor.
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.

Detailed Description

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

StartElement ( const String name  ) 

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


Member Function Documentation

StartElement* clone (  )  const [virtual]

Returns:
A cloned version of this StartElement object.

Implements Node.

String& name (  ) 

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& name (  )  const

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.

void setName ( const String  name  ) 

Parameters:
name The new name for this StartElement object.

void addAttribute ( const Attribute attribute  ) 

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:
attribute The attribute which is added to this object's attribute list.

const std::list<Attribute>& attributes (  )  const

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.

const String& attribute ( const String  attributeName  )  const

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:
attributeName The 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.

bool 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:
attributeName It is checked if an attribute with this attribute name exists.
Returns:
$true$ if an attribute with this name exists; $false$ otherwise.

const NamespaceContext& namespaceContext (  )  const

Returns:
NamespaceContext The namespace conText of this StartElment.
See also:
NamespaceContext

void setNamespaceContext ( const NamespaceContext conText  ) 

Parameters:
conText The new namespace conText for this StartElment.
See also:
NamespaceContext

const String& namespaceUri ( const String prefix  )  const

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

Parameters:
prefix The 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 operator== ( const Node node  )  const [virtual]

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:
node This 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 Node.

Copyright © 2008 The Tntnet Development Team
Tntnet 1.6