How to find a node in a XML file most efficiently (C++)?
<p>I have a XML file might contain thousands of nodes like below.</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;root&gt;
    &lt;node&gt;
        &lt;id&gt;0&lt;/id&gt;
        &lt;value&gt;data&lt;/value&gt;
    &lt;/node&gt;
    &lt;node&gt;
        &lt;id&gt;1&lt;/id&gt;
        &lt;value&gt;data&lt;/value&gt;
    &lt;/node&gt;
    &lt;node&gt;
        &lt;id&gt;2&lt;/id&gt;
        &lt;value&gt;data&lt;/value&gt;
    &lt;/node&gt;
&lt;/&lt;root&gt;
</code></pre>

<p>Each node has its "id" which guarantees be not duplicated to each other and possibly there are gaps between them.
My question is what is most efficient way by using boost to search a certain node by using node's id?</p>

<p>Thanks.</p>

<p>UPDATE
This is the way I did</p>

<pre><code>property_tree::wptree   ptree; // has been loaded somewhere

auto nodes = ptree.get_child(L"root");

bool bFound = false;

for (auto&amp; itr : nodes)
{
    auto &amp; rec = itr.second;
    int id = rec.get&lt;int&gt;(L"id", -1);
    if (id == nodeId)
    {
        bFound = true;
        // found it 
        //  get other values
        break;
    }
}
</code></pre>

<p>I do not think scanning whole the file to find an item is efficient.</p>