This commit is contained in:
Looly
2019-11-26 11:21:34 +08:00
parent de80af155c
commit 83460af7ef
18 changed files with 192 additions and 140 deletions

View File

@@ -1,17 +1,16 @@
package cn.hutool.core.util;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.xml.xpath.XPathConstants;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapBuilder;
import cn.hutool.core.map.MapUtil;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.w3c.dom.Document;
import cn.hutool.core.map.MapBuilder;
import cn.hutool.core.map.MapUtil;
import javax.xml.xpath.XPathConstants;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* {@link XmlUtil} 工具类
@@ -86,6 +85,15 @@ public class XmlUtilTest {
Assert.assertEquals("1", map.get("successCounts"));
}
@Test
public void xmlToMapTest2() {
String xml = "<root><name>张三</name><name>李四</name></root>";
Map<String, Object> map = XmlUtil.xmlToMap(xml);
Assert.assertEquals(1, map.size());
Assert.assertEquals(CollUtil.newArrayList("张三", "李四"), map.get("name"));
}
@Test
public void mapToXmlTest() {
Map<String, Object> map = MapBuilder.create(new LinkedHashMap<String, Object>())//