While the structure of the AST is the same, there is more detail than that in the actual XML file. In particular, there are attributes for the line number and column of tags. Which means you can write an XPath or Java rule against those attributes.
You can see an example here.
<TypeDeclaration BeginColumn="1" BeginLine="1" EndColumn="1" EndLine="10"
You can also generate this for your own file for testing using the PMD Eclipse plugin.