读书人

dom4j解析String门类的xml

发布时间: 2012-09-03 09:48:39 作者: rapoo

dom4j解析String类型的xml

??StringBuffer str = new StringBuffer();
??str.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
??.append("<Request xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"Request.xsd\">")
??.append("<Header><RequestApp Name=\"AppName\"/></Header>")
??.append("<Body><Data>")
??.append("<Cell Name=\"edDeptID\" Value=\"2\" Annotation=\"部门ID\" DataType=\"int\"/>")
??.append("<Cell Name=\"ou\" Value=\"11\" Annotation=\"组织机构代码\" DataType=\"string\"/>")
??.append("<Cell Name=\"edUnitCode\" Value=\"21\" Annotation=\"单位编码\" DataType=\"int\"/>")
??.append("<Cell Name=\"edName\" Value=\"31\" Annotation=\"部门全称\" DataType=\"string\"/>")
??.append("<Cell Name=\"edDisplayName\" Value=\"41\" Annotation=\"部门简称\" DataType=\"string\"/>")
??.append("<Cell Name=\"edMail\" Value=\"\" Annotation=\"电子邮件\" DataType=\"string\"/>")
??.append("<Cell Name=\"postalAddress\" Value=\"\" Annotation=\"通讯地址\" DataType=\"string\"/>")
??.append("<Cell Name=\"postalCode\" Value=\"71\" Annotation=\"邮政编码\" DataType=\"string\"/>")
??.append("<Cell Name=\"telephoneNumber\" Value=\"81\" Annotation=\"部门办公电话\" DataType=\"string\"/>")
??.append("<Cell Name=\"facsimileTelephoneNumber\" Value=\"9\" Annotation=\"部门传真号码\" DataType=\"string\"/>")
??.append("<Cell Name=\"edOrder\" Value=\"1\" Annotation=\"排序号\" DataType=\"int\"/>")
??.append("<Cell Name=\"edSuperDepartment\" Value=\"111\" Annotation=\"上级部门ID\" DataType=\"int\"/>")
??.append("<Cell Name=\"edIsLeaf\" Value=\"1\" Annotation=\"是否页节点\" DataType=\"string\"/>")
??.append("<Cell Name=\"edRemark\" Value=\"1\" Annotation=\"备注\" DataType=\"string\"/>")
??.append("<Cell Name=\"edStatus\" Value=\"1\" Annotation=\"状态\" DataType=\"int\"/>")
??.append("</Data><Data>")
??.append("<Cell Name=\"edDeptID\" Value=\"1\" Annotation=\"部门ID\" DataType=\"int\"/>")
??.append("<Cell Name=\"ou\" Value=\"1\" Annotation=\"组织机构代码\" DataType=\"string\"/>")
??.append("<Cell Name=\"edUnitCode\" Value=\"1\" Annotation=\"单位编码\" DataType=\"int\"/>")
??.append("<Cell Name=\"edName\" Value=\"1\" Annotation=\"部门全称\" DataType=\"string\"/>")
??.append("<Cell Name=\"edDisplayName\" Value=\"1\" Annotation=\"部门简称\" DataType=\"string\"/>")
??.append("<Cell Name=\"edMail\" Value=\"1\" Annotation=\"电子邮件\" DataType=\"string\"/>")
??.append("<Cell Name=\"postalAddress\" Value=\"1\" Annotation=\"通讯地址\" DataType=\"string\"/>")
??.append("<Cell Name=\"postalCode\" Value=\"1\" Annotation=\"邮政编码\" DataType=\"string\"/>")
??.append("<Cell Name=\"telephoneNumber\" Value=\"1\" Annotation=\"部门办公电话\" DataType=\"string\"/>")
??.append("<Cell Name=\"facsimileTelephoneNumber\" Value=\"1\" Annotation=\"部门传真号码\" DataType=\"string\"/>")
??.append("<Cell Name=\"edOrder\" Value=\"1\" Annotation=\"排序号\" DataType=\"int\"/>")
??.append("<Cell Name=\"edSuperDepartment\" Value=\"1\" Annotation=\"上级部门ID\" DataType=\"int\"/>")
??.append("<Cell Name=\"edIsLeaf\" Value=\"\" Annotation=\"是否页节点\" DataType=\"string\"/>")
??.append("<Cell Name=\"edRemark\" Value=\"1\" Annotation=\"备注\" DataType=\"string\"/>")
??.append("<Cell Name=\"edStatus\" Value=\"1\" Annotation=\"状态\" DataType=\"int\"/>")
??.append("</Data></Body></Request>");

?

以上是xml文件

?下面是具体实现解析xml

?

?

?

读书人网 >XML SOAP

热点推荐