{
////////////////////////////////////////////////////////////////
+ namespace rxpath
+ {
+ struct elem_name{
+ const char* name;
+ elem_name(const char* name_in) : name(name_in) {}
+ };
+
+ struct aster_{} aster;
+ }
+
+ ////////////////////////////////////////////////////////////////
+
struct node
{
enum node_types_e
///////////////////////////////////////////////////
- ::std::vector<element*> get_child_elements()
+ ::std::vector<element*> get_child_elements(const char* tagname=NULL)
{
::std::vector<element*> el;
for(size_t i=0; i<node_list.size(); i++)
{
node *p = node_list[i];
- if ( p->m_node_type == node::TYPE_ELEMENT )
+ if ( p->m_node_type == node::TYPE_ELEMENT &&
+ ( !tagname || tagname && ((element*)p)->name == tagname ) )
el.push_back((element*)p);
}
return el;
}
+
+ ::std::vector<attribute*> get_attributes(const char* attrname=NULL)
+ {
+ ::std::vector<attribute*> al;
+
+ for(size_t i=0; i<node_list.size(); i++)
+ {
+ node *p = node_list[i];
+ if ( p->m_node_type == node::TYPE_ATTRIBUTE &&
+ ( !attrname || attrname && ((attribute*)p)->name == attrname ) )
+ al.push_back((attribute*)p);
+ }
+ return al;
+ }
+
+ ///////////////////////////////////////////////////
+
+ //node_list_t select(_RxPath
+ ::std::vector<element*> operator / (const rxpath::elem_name& en)
+ {
+ return get_child_elements(en.name);
+ }
+
+ ::std::vector<element*> operator / (const rxpath::aster_&)
+ {
+ return get_child_elements();
+ }
+
+ ::std::vector<element*> operator / (const char* s)
+ {
+ if ( s[0] == '*' && s[1] == '\0' )
+ return get_child_elements();
+ else
+ return get_child_elements();
+ }
};
typedef ::std::vector<element*> element_list_t;