dom4j The prefix “xxx” for element "xxx:yyy" is not bound

String字符串类型xml

<?xml version="1.0" encoding="UTF-8"?>
<workorder>
  <basic:id>工单单号</basic:id>

  <basic:title>申请单标题</basic:title>

</workorder>

使用dom4j解析:DocumentHelper.parseText(condition);

出现如下错误

Error on line 1 of document : The prefix "basic" for element "basic:id" is not bound. Nested exception: The prefix "basic" for element "basic:id" is not bound.

解决办法:

1.在root节点添加属性: xmlns:basic="http://www.example.com"

root节点变成<workorder xmlns:basic="http://www.example.com">

2.删掉前缀basic只留下id(个人感觉这是废话)。

posted @ 2013-09-17 17:45  学习记录  阅读(1324)  评论(0编辑  收藏  举报