XML Tag. More...
#include <rxmltag.h>
Public Member Functions | |
RXMLTag (const RXMLTag &tag) | |
RXMLTag (const RString &name, RURI *xmlns=0) | |
int | Compare (const RString &name) const |
int | Compare (const RXMLTag &tag) const |
RString | GetFullName (void) const |
RString | GetName (void) const |
void | SetName (const RString &name) |
RURI * | GetNamespace (void) const |
void | SetNamespace (RURI *xmlns) |
RString | GetAttrValue (const RString &name) const |
RXMLAttr * | GetAttr (const RString &name) const |
bool | IsAttrDefined (const RString &name) const |
RXMLTag * | GetTag (const RString &name) const |
void | GetTags (const RString &name, RContainer< RXMLTag, false, false > &find) const |
RString | GetTagAttrValue (const RString &tag, const RString &attr) const |
void | InsertAttr (RXMLAttr *attr, bool overwrite=true) |
void | InsertAttr (RXMLStruct *xml, const RString &name, const RString &value, const RString &xmlns=RString::Null, bool overwrite=true) |
void | AddContent (const RString &text) |
RString | GetContent (void) const |
bool | HasContent (void) const |
virtual bool | IsEmpty (void) |
R::RCursor< RXMLAttr > | GetAttrs (void) const |
size_t | GetNbAttrs (void) const |
bool | Merge (RXMLStruct *xml, const RXMLTag *merge) |
virtual | ~RXMLTag (void) |
Public Member Functions inherited from RNode< RXMLStruct, RXMLTag, true > | |
RNode (void) | |
RNode (RXMLStruct *tree) | |
virtual void | Clear (void) |
RXMLTag * | GetParent (void) const |
RXMLTag * | GetFirst (void) const |
RXMLTag * | GetLast (void) const |
RXMLTag * | GetPrev (void) const |
RXMLTag * | GetNext (void) const |
size_t | GetNbNodes (void) const |
size_t | GetNbTotalNodes (void) const |
size_t | GetDepth (void) const |
RXMLTag * | GetNode (const TUse &tag) const |
bool | VerifyNode (size_t id) |
virtual double | GetUpOperationCost (void) const |
virtual | ~RNode (void) |
Private Attributes | |
RString | Name |
RString | Contains |
RContainer< RXMLAttr, true, true > | Attrs |
RURI * | Namespace |
Additional Inherited Members | |
Protected Attributes inherited from RNode< RXMLStruct, RXMLTag, true > | |
RXMLTag * | Parent |
RXMLTag * | Prev |
RXMLTag * | Next |
RXMLTag * | First |
RXMLTag * | Last |
size_t | NbSubNodes |
size_t | Depth |
Detailed Description
XML Tag.
This class provides a representation for a XML tag. It inherits from RNode.
Constructor & Destructor Documentation
Copy constructor. Create a tag with the same name and the same attributes but without the subnodes.
- Parameters
-
tag Original tag.
Construct a XML Tag.
- Parameters
-
name Name of the tag. xmlns Namespace of the tag.
|
virtual |
Destruct the XML Tag.
Member Function Documentation
int Compare | ( | const RString & | name | ) | const |
Compare a tag with a given name.
- Parameters
-
name Name used for the comparison.
- Returns
- 0 if the same, -1 or +1 if different.
int Compare | ( | const RXMLTag & | tag | ) | const |
Compare two tags.
- Parameters
-
tag Tag used for the comparison.
- Returns
- 0 if the same, -1 or +1 if different.
RString GetFullName | ( | void | ) | const |
Return the full name of the tag (including the namespace).
- Returns
- a string containing the name.
RString GetName | ( | void | ) | const |
Return the name of the tag.
- Returns
- a string containing the name.
void SetName | ( | const RString & | name | ) |
Set the name of the tag.
- Parameters
-
name Name of the tag.
RURI* GetNamespace | ( | void | ) | const |
Return the namespace of the tag.
- Returns
- a string containing the namespace.
void SetNamespace | ( | RURI * | xmlns | ) |
Set the namespace of the tag.
- Parameters
-
xmlns Namespace of the tag.
Return the value of an attribute. param name Name of the attribute.
- Returns
- a string containing the name or the null if the attribute wasn't found.
Return an attribute. param name Name of the attribute.
- Returns
- a pointer or null if the attribute wasn't found.
bool IsAttrDefined | ( | const RString & | name | ) | const |
Test if an attribute is defined. param name Name of the attribute.
- Returns
- True if the attribute exists.
Find the first tag with a given name.
- Parameters
-
name Name of the tag to find.
- Returns
- Pointer to the element.
void GetTags | ( | const RString & | name, |
RContainer< RXMLTag, false, false > & | find | ||
) | const |
Find the all tags with a given name.
- Parameters
-
name Name of the tags to find. find Container that will hold the tags.
Get the value of an attribute of the first tag with a given name. param tag Name of the tag. param attr Name of the attribute.
- Returns
- a string containing the value of the attribute or a null string if either the tag wasn't found or the attribute was not found.
void InsertAttr | ( | RXMLAttr * | attr, |
bool | overwrite = true |
||
) |
Insert an attribute. If the attribute already exist, the value can be overwritten depending of the second parameter.
- Parameters
-
attr Attribute to insert overwrite Overwrite existing parameter.
void InsertAttr | ( | RXMLStruct * | xml, |
const RString & | name, | ||
const RString & | value, | ||
const RString & | xmlns = RString::Null , |
||
bool | overwrite = true |
||
) |
Insert an attribute. If the attribute already exist, the value can be overwritten depending of the third parameter.
- Parameters
-
xml If not null, the method RXMLStruct::NewAttr is used to create the attribute. If not, a RXMLAttr is created. name Name of the attribute. value Value of the attribute. xmlns XML Namespace. overwrite Overwrite existing parameter.
void AddContent | ( | const RString & | text | ) |
Add a string to the content of the tag.
- Parameters
-
text Text to add.
RString GetContent | ( | void | ) | const |
- Returns
- the text containing in the tag.
bool HasContent | ( | void | ) | const |
See if the tag has a content.
|
virtual |
Test if the tag is empty, i.e. it has no sub-nodes, no parameters and no content.
Reimplemented from RNode< RXMLStruct, RXMLTag, true >.
R::RCursor<RXMLAttr> GetAttrs | ( | void | ) | const |
Get a Cursor on the attributes.
- Returns
- GXMLAttrCursor.
size_t GetNbAttrs | ( | void | ) | const |
Get the number of attributes.
bool Merge | ( | RXMLStruct * | xml, |
const RXMLTag * | merge | ||
) |
Merge two tag if they are identical (based on the Compare method of RXMLStruct). The attributes of merge replace (when necessary) the attributes. Each sub-tag of merge is merged if it correspond to one of the sub-tags,else merge it is added.
- Parameters
-
merge Tag to merge. xml XML Structure.
- Returns
- true if the merge could be done.
Field Documentation
|
private |
The name of the tag.
|
private |
The contain of the tag
|
private |
The attributes of the tag.
|
private |
Namespace.