namespace in xmlcursor

P

Peter Parker

The code works if I remove the namespace, but it's not working with the
namespace. Please help. Thanks.
========

try{

String sXml = "<n1:foo
xmlns:n1='a'><n1:c><b>0</b><b>1</b><b>2</b><b>3</b><b>4</b><b>5</b><b>6</b></n1:c></n1:foo>";
//<= not working if using namespace here

XmlObject sd=XmlObject.Factory.parse(sXml);
XmlCursor sdcursor=sd.newCursor();

sdcursor.toFirstChild();
String xqNamespace ="declare namespace n1='a';";

sdcursor.selectPath( "$this//n1:c"); //not working if using namespace here

while (sdcursor.toNextSelection())
{
System.out.println(sdcursor.getTextValue());
}
catch(XmlException e) {
e.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
 
S

Simon Brooke

Peter Parker said:
The code works if I remove the namespace, but it's not working with the
namespace. Please help. Thanks.

This isn't code, it's incoherence. The purpose of a high level programming
language is only secondarily to communicate with the compiler; it's
primarily to communicate with The Programmer Who Is To Come After You.
This communicates nothing. What are you trying to do, and what
do 'working' and 'not working' mean in this context?

If you cannot write perspicuous code, at least learn to write useful
comments.

--
(e-mail address removed) (Simon Brooke) http://www.jasmine.org.uk/~simon/

;; If you're doing this for fun, do what seems fun. If you're
;; doing it for money, stop now.
;; Rainer Deyke
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top