diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-01-18 11:18:35 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-01-18 11:18:35 +0000 |
commit | 9bc19368f2fe81fec271c57ac1583c6a9eb1d014 (patch) | |
tree | b6d4eb402b7970ed00d5bbf6deb733ed9b9e3d00 /src/pugixml.cpp | |
parent | 355d0f06971002efc2aca5a3bf2a8ecebef9b7d6 (diff) |
Added find_child_by_attribute
git-svn-id: http://pugixml.googlecode.com/svn/trunk@107 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src/pugixml.cpp')
-rw-r--r-- | src/pugixml.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index ccaec6a..06bd0ba 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -2411,6 +2411,60 @@ namespace pugi n._root->destroy();
}
+ xml_node xml_node::find_child_by_attribute(const char* name, const char* attr_name, const char* attr_value)
+ {
+ if (empty()) return xml_node();
+
+ for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
+ if (i->name && !strcmp(name, i->name))
+ {
+ for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute)
+ if (!strcmp(attr_name, a->name) && !strcmp(attr_value, a->value))
+ return xml_node(i);
+ }
+
+ return xml_node();
+ }
+
+ xml_node xml_node::find_child_by_attribute_w(const char* name, const char* attr_name, const char* attr_value)
+ {
+ if (empty()) return xml_node();
+
+ for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
+ if (i->name && !impl::strcmpwild(name, i->name))
+ {
+ for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute)
+ if (!impl::strcmpwild(attr_name, a->name) && !impl::strcmpwild(attr_value, a->value))
+ return xml_node(i);
+ }
+
+ return xml_node();
+ }
+
+ xml_node xml_node::find_child_by_attribute(const char* attr_name, const char* attr_value)
+ {
+ if (empty()) return xml_node();
+
+ for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
+ for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute)
+ if (!strcmp(attr_name, a->name) && !strcmp(attr_value, a->value))
+ return xml_node(i);
+
+ return xml_node();
+ }
+
+ xml_node xml_node::find_child_by_attribute_w(const char* attr_name, const char* attr_value)
+ {
+ if (empty()) return xml_node();
+
+ for (xml_node_struct* i = _root->first_child; i; i = i->next_sibling)
+ for (xml_attribute_struct* a = i->first_attribute; a; a = a->next_attribute)
+ if (!impl::strcmpwild(attr_name, a->name) && !impl::strcmpwild(attr_value, a->value))
+ return xml_node(i);
+
+ return xml_node();
+ }
+
#ifndef PUGIXML_NO_STL
std::string xml_node::path(char delimiter) const
{
|