public class XmlUtil extends Object
Constructor and Description |
---|
XmlUtil() |
Modifier and Type | Method and Description |
---|---|
static Map<String,Object> |
elementToMap(org.dom4j.Element element,
Map<String,Object> map)
递归遍历xml子节点,转换Map
|
static Object |
mapToBean(Map<String,Object> map,
Class clazz)
将Map对象通过反射机制转换成Bean对象
|
static Object |
xmlStrToBean(String xmlStr,
Class clazz)
xml字符串转换成bean对象
|
static Object |
xmlStrToJavaBean(String xmlStr,
Class clazz)
将xml格式字符串转换成Bean对象
多级子节点递归遍历
|
static Map<String,Object> |
xmlStrToMap(String xmlStr)
将xml格式的字符串转换成Map对象
|
public static Object xmlStrToBean(String xmlStr, Class clazz)
xmlStr
- xml字符串clazz
- 待转换的classpublic static Map<String,Object> xmlStrToMap(String xmlStr) throws Exception
xmlStr
- xml格式的字符串Exception
- 异常public static Object xmlStrToJavaBean(String xmlStr, Class clazz)
xmlStr
- clazz
- Exception
public static Map<String,Object> elementToMap(org.dom4j.Element element, Map<String,Object> map)
element
- map
- Copyright © 2021. All rights reserved.