I am trying to modify a soapmessage. The message follows:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance " xmlns:soapenc="
http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="
http://www.w3.org/2001/XMLSchema"><env:Header/><env:Body><n1:sendNotification xmlns:n1="
http://us.abc.com/notification"><n2:attachmentURL xmlns:n3="java:language_builtins.lang" xmlns:n2="java:com.abc.us.mw.notifier.beans" xsi:type="n3:ArrayOfString"><n3:string>D:\abc1.txt</n3:string><n3:string>D:\app.properties</n3:string></n2:attachmentURL><n4:body xmlns:n4="java:
com.abc.us.mw.notifier.beans" xsi:nil="true"/><n5:fileDir xmlns:n5="java:com.abc.us.mw.notifier.beans" xsi:nil="true"/><n6:recipients xmlns:n6="java:com.abc.us.mw.notifier.beans
" xsi:type="n6:ArrayOfNotificationRecipient"><n6:NotificationRecipient><n6:context xsi:nil="true"/><n6:id>
[EMAIL PROTECTED] </n6:id><n6:recipientType>TO</n6:recipientType></n6:NotificationRecipient></n6:recipients><n7:runtimeAttachmentBaseURL xmlns:n7="java:com.abc.us.mw.notifier.beans
" xsi:nil="true"/><n8:sender xmlns:n8="java: com.abc.us.mw.notifier.beans">
[EMAIL PROTECTED]</n8:sender><n9:singleMail xmlns:n9="java:com.abc.us.mw.notifier.beans">true</n9:singleMail><n10:soapAttachment xmlns:n10="java: com.abc.us.mw.notifier.beans
" xsi:nil="true"/><n11:subject xmlns:n11="java:com.abc.us.mw.notifier.beans">IFC message from abc India</n11:subject><n12:templateCode xmlns:n12="java: com.abc.us.mw.notifier.beans
">4193</n12:templateCode></n1:sendNotification></env:Body></env:Envelope>
Now I want to modify the elemnt attacmentURL. For this I converted the string to a Document. I formulated a XPATH query from XMLSPY editor. But the list that it returns is null. Here is my code:
org.dom4j.Document doc2 = DocumentHelper.parseText(<the string mentioned above>);
XPath xpathSelector = DocumentHelper.createXPath("/env:Envelope/env:Body/n1:sendNotification/n2:attachmentURL");
List results = xpathSelector.selectNodes(doc2);
List results = xpathSelector.selectNodes(doc2);
This list is null. What I found that it is not recognising the namespace n1, n2 etc. Because when I am removing this namespaces then the output is giving the desired result. As I can't change the message, is there any way out?
--
Regards,
Saurav