/** * Produces XML representation of the provided {@link AccessibilityElement accessibility elements} hierarchy, * compatible with the Android`s AccessibilityNodeInfo XML dump (and the screen dump as it is the same thing). * * @param hierarchy * - the hierarchy of {@link AccessibilityElement elements} as a tree * @return the hierarchy as an XML document */ public static String serialize(Tree<AccessibilityElement> hierarchy) { AccessibilityXmlSerializer serializer = new AccessibilityXmlSerializer(); serializer.startTag("hierarchy"); // if the hierarchy starts to contain information about the rotation this should be changed serializer.addAttribute("rotation", "0"); serialize(hierarchy.getRoot(), serializer); serializer.endTag("hierarchy"); return serializer.xmlBuilder.toString(); }