How to set Default Tab when use xml

from this xml :

<?xml version="1.0"?>

Tab 2-1

Tab 2-2

Tab 2-3

Tab 2-4

and id html i write :

it work when i take out comment at alert() why?

The XML loading is async, so in moment when command next to loadXML executed data not loaded yet, it just in loading process.
To be sure that data loaded you can use second parameter of loadXML command

        // code here will be called only after data loading