| 171 | /// Inverse of `#toXml`. Parses the XML text and hands the resulting |
| 172 | /// Element to the registered mapper. |
| 173 | public static <T> T fromXml(String xml, Class<T> type) { |
| 174 | if (xml == null) { |
| 175 | return null; |
| 176 | } |
| 177 | Mapper<T> m = get(type); |
| 178 | if (m == null) { |
| 179 | throw missing(type); |
| 180 | } |
| 181 | XMLParser p = new XMLParser(); |
| 182 | Element root = p.parse(new StringReader(xml)); |
| 183 | return m.readXml(root); |
| 184 | } |
| 185 | |
| 186 | /// Parses XML read from a `Reader` without fully buffering it first. |
| 187 | public static <T> T fromXml(Reader xml, Class<T> type) { |