// parses attributes into a map private static ImmutableMap <string, string> parseAttributes(XMLStreamReader reader) { ImmutableMap <string, string> attrs; int attributeCount = reader.AttributeCount + reader.NamespaceCount; if (attributeCount == 0) { attrs = ImmutableMap.of(); } else { ImmutableMap.Builder <string, string> builder = ImmutableMap.builder(); for (int i = 0; i < reader.AttributeCount; i++) { builder.put(reader.getAttributeLocalName(i), reader.getAttributeValue(i)); } attrs = builder.build(); } return(attrs); }