@Test public void fromXml() { String string = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "\n" + "\n<root>" + "\n<Details>" + "\n <detail-a>" + "\n" + "\n <detail> attribute 1 of detail a </detail>" + "\n <detail> attribute 2 of detail a </detail>" + "\n <detail> attribute 3 of detail a </detail>" + "\n" + "\n </detail-a>" + "\n" + "\n <detail-b>" + "\n <detail> attribute 1 of detail b </detail>" + "\n <detail> attribute 2 of detail b </detail>" + "\n" + "\n </detail-b>" + "\n" + "\n" + "\n</Details>" + "\n</root>"; assertEquals("{Details={detail-a={detail=[ attribute 1 of detail a , attribute 2 of detail a , attribute 3 of detail a ]}, " + "detail-b={detail=[ attribute 1 of detail b , attribute 2 of detail b ]}}}", FromXml.fromXml(string).toString()); }
public static Object fromXml(final String xml) { try { final java.io.InputStream stream = new java.io.ByteArrayInputStream(xml.getBytes("UTF-8")); final javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); final org.w3c.dom.Document document = factory.newDocumentBuilder().parse(stream); return createMap(document.getDocumentElement()); } catch (Exception ex) { throw new IllegalArgumentException(ex); } }
FromXml { public static Object fromXml(final String xml) { try { final java.io.InputStream stream = new java.io.ByteArrayInputStream(xml.getBytes("UTF-8")); final javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); final org.w3c.dom.Document document = factory.newDocumentBuilder().parse(stream); return createMap(document.getDocumentElement()); } catch (Exception ex) { throw new IllegalArgumentException(ex); } } }
FromXml { public static Object fromXml(final String xml) { try { final java.io.InputStream stream = new java.io.ByteArrayInputStream(xml.getBytes("UTF-8")); final javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); final org.w3c.dom.Document document = factory.newDocumentBuilder().parse(stream); return createMap(document.getDocumentElement()); } catch (Exception ex) { throw new IllegalArgumentException(ex); } }  }
FromXml { public static Object fromXml(final String xml) { try { final java.io.InputStream stream = new java.io.ByteArrayInputStream(xml.getBytes("UTF-8")); final javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); final org.w3c.dom.Document document = factory.newDocumentBuilder().parse(stream); return createMap(document.getDocumentElement()); } catch (Exception ex) { throw new IllegalArgumentException(ex); } }  static Object fromXml(final String xml); }
FromXml { public static Object fromXml(final String xml) { try { final java.io.InputStream stream = new java.io.ByteArrayInputStream(xml.getBytes("UTF-8")); final javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); final org.w3c.dom.Document document = factory.newDocumentBuilder().parse(stream); return createMap(document.getDocumentElement()); } catch (Exception ex) { throw new IllegalArgumentException(ex); } }  static Object fromXml(final String xml);  }