Lei,

that is normal!
Either you change your XPath expression to only filter the element name
*String s = document.valueOf("//*[local-name()='serviceRoot']/*[local-name()='serviceMethod']");

*or you use another method for XPath matching where you can
addNamespace("intx","http://B2Bi.seaie.ccb.com/InTxB2Bi002 <http://b2bi.seaie.ccb.com/InTxB2Bi002>");
then match with expression:
   *"//*intx*:serviceRoot/*intx*:serviceMethod"
*hope that helps.

paul
*
*
雷雨平 wrote:
Hello everyone! Would you do me a favor?
I have a XML string:
<!--     begin    -->
<?xml version="1.0" encoding="UTF-8"?>
<serviceRoot *xmlns*=" http://B2Bi.seaie.ccb.com/InTxB2Bi002 <http://b2bi.seaie.ccb.com/InTxB2Bi002>" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance <http://www.w3.org/2001/XMLSchema-instance>">
  <serviceName>TelecomService</serviceName>
  <servicePort>TelecomService</servicePort>
  <serviceMethod>cxCharge</serviceMethod>
  <appKey>123</appKey>
</serviceRoot>
<!--     end    -->
// I want to read the text of <serviceMethod> with valueOf(String xpathExpression) method:
*String s = document.valueOf("//serviceRoot/serviceMethod");*
// The "s" shuld be "cxCharge", but it is "".
I found the "xmlns" is the cause of it. If I set xmlns to "" or delete it, I will get string I expected. The xmlns always exsits and can't modify. How can I get expected string in this case?
*Thank you very much!!* :-)
Lei YuPing



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
dom4j-dev mailing list
dom4j-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to