Closed GoogleCodeExporter closed 9 years ago
"iteration" is meant to be attribute.
Original comment by calvin.c...@gmail.com
on 12 Oct 2011 at 2:52
find_child_by_attribute functions were not intended for iteration. Achieving
iteration can be done by using attribute() with (arguably) simpler code, i.e.
for (pugi::xml_node child = node.find_child_by_attribute("item", "type",
"text"); child; child = child.next_sibling_by_attribute("item", "type", "text"))
{ ... }
vs
for (pugi::xml_node child = node.child("item"); child; child =
child.next_sibling("item"))
if (strcmp(child.attribute("type").value(), "text") == 0)
{ ... }
Note that the attribute text/value is not duplicated in the second example,
making it potentially less error prone.
find_child_by_attribute usage for finding makes the code shorter and more
readable (without it you'd need an explicit loop) - for iteration it does not
make much sense.
It is possible to make a new iteration functionality to make this code simpler,
but it does not occur frequent enough; adding next_sibling variants will
therefore unnecessarily clutter the interface.
I'd suggest changing the code to explicitly check the attribute value, or, if
you're convinced that next_sibling variants are useful, add them to your own
header as free functions to keep pugixml unmodified.
Original comment by arseny.k...@gmail.com
on 3 Apr 2012 at 2:06
Original issue reported on code.google.com by
calvin.c...@gmail.com
on 11 Oct 2011 at 9:18Attachments: