Package cn.net.pap.common.file.xml
Class XmlParseUtil
java.lang.Object
cn.net.pap.common.file.xml.XmlParseUtil
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionaddParentInfo(List<Map<String, Object>> flatList) 为平铺的目录列表添加父节点IDstatic DocumentgetDocumentByPath(String filePath) 从文件路径创建 Document 对象static booleanhasRootPath(Document document, String rootPath) 检查 XML 中是否存在指定路径parse(Document document, String root, Map<String, String> nodeMap, Map<String, String> nodesMap, Map<String, Map<String, String>> nodeFromAttributeMap, Map<String, Map<String, String>> nodesFromAttributeMap, Map<String, Map<String, String>> attributesMap, String delimiter, Map<String, String> nodesDelimiterMap) 核心解析方法static voidprintWithParent(List<Map<String, Object>> list) 打印带父子关系和缩进的结果
-
Method Details
-
getDocumentByPath
从文件路径创建 Document 对象- Throws:
IOException
-
parse
public static List<Map<String,Object>> parse(Document document, String root, Map<String, String> nodeMap, Map<String, String> nodesMap, Map<String, Map<String, String>> nodeFromAttributeMap, Map<String, Map<String, String>> nodesFromAttributeMap, Map<String, Map<String, String>> attributesMap, String delimiter, Map<String, String> nodesDelimiterMap) 核心解析方法- Parameters:
document-root- 根节点XPath路径nodeMap- 单节点映射配置nodesMap- 多节点映射配置nodeFromAttributeMap- 从属性提取单值配置nodesFromAttributeMap- 从属性提取多值配置attributesMap- 带属性的节点配置delimiter- 多值合并分隔符nodesDelimiterMap- 特定字段分隔符配置- Returns:
-
hasRootPath
检查 XML 中是否存在指定路径 -
addParentInfo
为平铺的目录列表添加父节点ID- Parameters:
flatList- 平铺的目录项列表- Returns:
- 添加了parentId的列表
-
printWithParent
打印带父子关系和缩进的结果
-