public static void convert(InputStream is, PrintWriter out, TaskMonitor monitor)
			throws IOException, CancelledException {

		monitor.setMessage("Converting Android Binary XML to Text...");

		AXmlResourceParser parser = new AXmlResourceParser();
		parser.open(is);

		try {
			int indent = -1;
			int type;
			while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) {
				monitor.checkCancelled();

				StringBuffer buffer = new StringBuffer();
				switch (type) {
					case XmlPullParser.START_DOCUMENT:
						buffer.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
						buffer.append("\n");
						break;
					case XmlPullParser.START_TAG: {
						++indent;

						buffer.append(StringUtilities.pad("", '\t', indent));
						buffer.append("<");
						buffer.append(getNamespacePrefix(parser.getPrefix()));
						buffer.append(parser.getName());
						buffer.append("\n");

						int namespaceCountBefore = parser.getNamespaceCount(parser.getDepth() - 1);
						int namespaceCount = parser.getNamespaceCount(parser.getDepth());

						++indent;

						for (int i = namespaceCountBefore; i != namespaceCount; ++i) {
							buffer.append(StringUtilities.pad("", '\t', indent));
							buffer.append("xmlns:");
							buffer.append(parser.getNamespacePrefix(i));
							buffer.append("=");
							buffer.append("\"");
							buffer.append(parser.getNamespaceUri(i));
							buffer.append("\"");
							buffer.append("\n");
						}

						for (int i = 0; i < parser.getAttributeCount(); ++i) {
							buffer.append(StringUtilities.pad("", '\t', indent));
							buffer.append(getNamespacePrefix(parser.getAttributePrefix(i)));
							buffer.append(parser.getAttributeName(i));
							buffer.append("=");
							buffer.append("\"");
							buffer.append(getAttributeValue(parser, i));
							buffer.append("\"");
							buffer.append("\n");
						}

						buffer.append(StringUtilities.pad("", '\t', indent));
						buffer.append(">");
						buffer.append("\n");

						--indent;
					}
						break;
					case XmlPullParser.END_TAG: {
						buffer.append(StringUtilities.pad("", '\t', indent));
						buffer.append("<");
						buffer.append("/");
						buffer.append(getNamespacePrefix(parser.getPrefix()));
						buffer.append(parser.getName());
						buffer.append(">");
						buffer.append("\n");
						--indent;
					}
						break;
					case XmlPullParser.TEXT: {
						buffer.append(StringUtilities.pad("", '\t', indent));
						buffer.append(parser.getText());
						buffer.append("\n");
					}
				}

				out.print(buffer.toString());
			}
			out.println();
		}
		catch (XmlPullParserException | ArrayIndexOutOfBoundsException e) {
			throw new IOException("Failed to read AXML file", e);
		}
		finally {
			parser.close();
		}
	}
NOTE: most of this logic was copied form AndroidXmlFileSystem, which had the following
note: "most of this code was hijacked from AXMLPrinter.java class!"
Ghidra/Features/FileFormats/src/main/java/ghidra/file/formats/android/xml/AndroidXmlConvertor.java