Irbis
Irbis

Reputation: 1491

pugixml - check if node exists or not

I get a child node this way:

pugi::xml_node child = root.child("aaa")

I would like to check if that child node exists. Should I just call child.empty() ?

Upvotes: 0

Views: 2508

Answers (1)

acraig5075
acraig5075

Reputation: 10756

The xml_node class has a logical bool operator overload that allows you to check that it exists by simply calling

if (child) { ... }

and similarly an operator! for checking if it doesn't exist with

if (!child) { ... }

Upvotes: 5

Related Questions