Use XPath!
If you have ever tried to process html using regexes
Like Regexes for the DOM
Examples:
//BBB[@id='b1']
Selects BBB elements which have attribute id with value b1
//CCC/*
Select all elements enclosed by element CCC
/AAA/BBB[last()]
Select the last BBB child of element AAA