java + XML + dom4j

Hi,I have an XML file like this:articleSet article   title    /title   author   /author /article article    title    /title   author   /author /article/articleSetusing dom4j I put this XML into a org.dom4j.Document (named xmlDoc) andfor each "article" Node I wuold like to do some stuff so I wrote this codeIterator iter = xmlDoc.selectNodes("//article").iterator();	while(iter.hasNext()){		Node n = (Node)iter.next();		System.out.println(n.asXML());                System.out.println(n.selectSingleNode("//title").getText());	}the problem is that the first "println" prints correctly the content ofeach "article" Node but the second prints always the FIRST article titlebecause the XPath search is done on entire document and not only insidethe current node.Why this behaviour? I made some mistakes?dat
0
dat
10/16/2007 3:19:31 PM
comp.lang.java.programmer 52319 articles. 0 followers. Post Follow

0 Replies
188 Views

Similar Articles

[PageSpeed] 56
Reply:
Similar Artilces:

Cisco 79xx phone XML services
Hello all. I'm starting a game with Cisco IPPhones XML services. My first try is to push a test page to the phone. Here is the perl script I'm trying to use with no luck so far. -- #!/usr/bin/perl -w use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $uid = 'John'; my $pwd = 'Doe'; my $uri = '192.168.2.2/cgi-bin/test.pl'; my $phoneIp = '192.168.2.10'; my $xml = "<CiscoIPPhoneExecute><ExecuteItem URL=\"".$uri."\"/></CiscoIPPhoneExecute>"; $ua->credentials("$phoneIp:80", ...

Unit test discovery with XML Runner?
Hey All, I've just started with the unittest module and I love it. I've been using t= est discovery- "python -m unittest discover" from the command line- so that= I can distribute my tests amongst files instead of having tp manage them a= ll. I'd like to publish the test results, though. Googling pointed me to xm= lrunner, which seems perfect, but requires me to add the if name=3D=3D'__ma= in__ line to all my tests, which isn't run my test discovery. Is there a wa= y to use xml runner with test discovery, or another way to solve the proble= m? -Lucre...

java
Hello All, What is the present state of opengl 'binding' to java (or vice versa). The picture emerging from the internet confuses me. Any comments gratefully received. Ivan "ivan danicic" <ivan@goaway.spam> wrote in message news:aWq8f.7097$iD.5529@fe2.news.blueyonder.co.uk... > Hello All, What is the present state of opengl 'binding' to java (or vice > versa). The picture emerging from the internet confuses me. Any comments > gratefully received. > Ivan > "jogl" is still active and probably one of the most complete. I've assumed ...

Java Web Console
Hello, What security restrictions should be considered when accessing Solaris 10 Web Console using root account? I have no problem to log in using another user account, but my root password seems not to work.... Feb 19 15:24:15 dwsol Sun Java(TM) Web Console[704]: [ID 197375 daemon.warning] Authentication of user {0} failed. bash-3.00# /usr/sbin/smcwebserver status Sun Java(TM) Web Console is running bash-3.00# cacaoadm restart bash-3.00# /usr/sbin/smcwebserver restart Restarting Sun Java(TM) Web Console Version 3.0.2 ... The console is running bash-3.00# svcs -a |grep webconsole onli...

Java run-time error in starting Hudson
I followed the instructions to install Hudson at http://weblogs.java.net/blog/kohsuke/archive/2007/03/installing_huds.html Simply download hudson.war and run java -jar hudson.war But I get this run-time error: Running from: /cgbu/home0/cgbubldt/hudson/hudson.war [Winstone 2009/07/20 13:09:41] - Beginning extraction from war file [Winstone 2009/07/20 13:10:06] - No webapp classes folder found - / cgbu/home0/cgbubldt/.hudson/war/WEB-INF/classes 20-Jul-09 1:10:06 PM hudson.WebAppMain contextInitialized SEVERE: Failed to initialize Hudson java.lang.NoClassDefFoundError: hudson.model.Hudson ...

XSD Validation of XML
I have an XSD that defines a type of engine. Depending upon which of the 200 <engineType>s is selected there are different legal values for <part> fields like <partLife> and <partCost>. I would like to use XSD to validate the XML to ensure that lives and costs for parts are correct, but I don't see a way to do that without creating separate XSD for each engine, which is silly because -- with the exception of the valid range for part data -- the XSD holds for all engines. How have others tackled this one? vm ...

Calling IDL Objects from JAVA
Folks, We are working on a new web portal that uses JAVA code for most of its operations. We wish to add some graphical functionality to the web page, so we are using the JAVA bridge to call some already defined IDL objects that open a file, process the data, create a PNG file, and display it on the web page. All of this works reasonably well. (We have had some weird problems with the IDL JAVA Bridge Assistant Wizard, or whatever it is calling itself these days, but for the moment we have overcome these.) Our main problem is that our IDL objects use a LOT of keywords in their methods. Spec...

Java in Java
Is it possible to download a Java app (applet etc?) and run it inside a desktop Java app? -- Dirk http://www.transcendence.me.uk/ - Transcendence UK http://www.theconsensus.org/ - A UK political party http://www.onetribe.me.uk/wordpress/?cat=5 - Our podcasts on weird stuff Dirk Bruere at NeoPax wrote: > Is it possible to download a Java app (applet etc?) and run it inside a > desktop Java app? > Quite likely, but you won't necessarily get the same security model, unless you were careful about it. -- Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/&g...

Using wildcard character in web.xml with Tomcat 5
I am trying to achieve the following: <servlet-mapping> <servlet-name>servletA</servlet-name> <url-pattern>/a*</url-pattern> </servlet-mapping> This should include /a, /aa, /abc/123 etc. I notice that servlet 2.4 doesn't treat * as a wildcard character in this case. Therefore, servletA would only be called if the URL is exactly /a*. I need to create this pattern for all characters and numbers except when the path starts with '/_' (which in this case the broser should simply display the resource as requested). Therefore, I can not use ...

US-NJ: Princeton-Jr. Java Web Developer
************************************************************** JobCircle.com - Careers, Content and Community for Technology professionals in the Northeastern United States! Jobcircle.com provides resume submission, classified searches, eLearning, hundreds of career development articles, tech news, and more to tens of thousands of Technology professionals in your area - visit us today at http://www.jobcircle.com! !!! Voted a TOP 50 Career Web Site in 2002 by CareerXRoads !!! ************************************************************** Job Title: Jr. Java Web Developer J...

Java navigation bar
Anyone know a good site that'll teach you how to make a drop-down navigation bar? I assume it is javascript In article <20031015232805.29165.00000668@mb-m06.aol.com>, kkiely@aol.comnojunk enlightened us with... > Anyone know a good site that'll teach you how to make a drop-down navigation > bar? I assume it is javascript > Why re-invent the wheel? There's tons of free ones out there. Try http://www.dynamicdrive.com ------------------------------------------------- ~kaeli~ Jesus saves, Allah protects, and Cthulhu thinks you'd make a nice sandwich. http://www...

US-TX-Austin: Java Developer, Web Logic, Web servers, EJB, JSP, Linux; 2040 hrs. (45360214411)
US-TX-Austin: Java Developer, Web Logic, Web servers, EJB, JSP, Linux; 2040 hrs. (45360214411) ============================================================================================== Position: Java Developer Reference: ZYD00205 Location: Austin TX Duration: 2040 h Skills: Progressive information technology experience and responsibility. Knowledge of Internet application servers (especially Web Logic), Web servers, EJB, JSP, Linux, Oracle, OO analysis/design, and multiple programming languages. ...

Practically Free Live 3 to 5 day Online Codecamps on Grails, Rails, jQuery, Spring, Java SE, Java EE, HTML5, Android
From July 23rd, 2013, JPassion.com is going to offer 3 to 5 days "live", "i= nstructor-led", "hands-on" style, "intensity guaranteed" codecamps (be read= y to code!) to all paying members of JPassion.com for free. Yes, for FREE. = Each of these codecamps would typically cost between $2000 to $4000. Now w= ith a paying membership of JPassion.com, which is $99 per year for now, you= can attend all of these live codecamps without paying a single extra dolla= r. Moving forward, we are planning to offer one or two codecamps per month.= Popular code...

java.policy question 471540
First let me say that I've used Google and come up with numerous answers (too numerous!). I'm really looking for pointers more than the direct answers as direct answer will most likely leave me with more questions. I'm currently running Sun Java 1.5.0 and the initial work is on Firefox 1.0. Later I'll work on IE. I'm working on an applet which will eventually sit on a device where it will be served from. But for now I need to run the applet from another machine and, of course, it gets a security violation. To get around this I search the web and found that I can change the...

requirement for Java multi thread @sunnyvale, ca
hi Folks, Job Title: Java Multi-Threading Location : Sunnyvale, CA Duration: 12 months Need a hands-on developer with: * Strong server side Java skills * Fluent in developing multi-threaded apps * Experience developing applications with Cassandra with high read/write operations * Comfortable performance tuning app * Developed apps on Linux Strong JAVA experience building Multithreading / Scalable applications SEND RESUMES TO JWHITE@JBSAC.COM ...

XML Editor Recommendation
I was looking around for XML editors and searching through this group, I found: http://www.oxygenxml.com/ http://www.xmlmind.com/ http://www.editix.com/ http://www.exchangerxml.com/ The primary requirement is that the editor runs under both Windows XP and MacOSX. I was wondering if anyone would care to give their recommendation(s) or opinion(s) on what editors to avoid (because they crash often, simply don't work well, etc.). Is there an editor or two out there that are considered to be 'top-of-the-line'? If you have done your own comparative analysis of the various available...

Java 6 Update 4 Application JDialog labelled (Java Applet Window)
Running Vista, Home Premium; Java 1.6 SERVER VM Update 4 using thefollowing command line:java.exe -server -dsa -Dsun.java2d.noddraw=true -Xbatch -Xss256k -Xms300m -Xmx300m -Xnoclassgc -XX:+RelaxAccessControlCheck -XX:MaxInlineSize=8192 -XX:-DontCompileHugeMethods -XX:+ForceTimeHighResolution -XX:-TieredCompilation -XX:CompileThreshold=20 -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:MaxGCPauseMillis=150 -XX:CICompilerCount=1 -XX:ThreadStackSize=256 -XX:+AggressiveOpts -cpsZoneTrader.jar;sZoneTraderAuth.jar;sZoneTraderSounds.jar;sZoneTraderChart.jar;sZoneTraderContracts.jarcom/twc/trader...

Oreilly upload and java bean
Hi, I am running tomcat 5 and have a form as jsp page. That form has lots of fields and am using oreilly's Multiparser class to upload a file from that form. For uploading the enctype should be multipart/form-data and it works fine. Now in the form I wanted to add a bean which will validate the form before processing it. I want validation to be done on server side. I am submitting the form to itself and then calling a bean. The bean does not run as it should be. The jsp:setProperty tag does not set the property. After a little testing I found that if I remove enctype it works fine. So t...

$links wiyh java
Hi all, Does somebody know how to get the content of the field "$Links" ? This field is created when you insert links in a document. With java if I use item.getText or get Value the result is empty with item.getType I have type=NOTELINKS Thanks Paola ...

Java Problem
Hello. I have two applications that run off Java. One of them requires that you uncheck the install to Internet Explorer option during setup while the other app requires that you check it. consequently, only one program will run at a time. is there any way i can get around this so i can run them simultaneously? thanks richard ...

US-TX-San Antonio: Filenet Program Analyst,Visual Basic,Java,ASP,HTML, .Net (45357114979)
US-TX-San Antonio: Filenet Program Analyst,Visual Basic,Java,ASP,HTML, .Net (45357114979) ========================================================================================= Position: Filenet Program Analyst Reference: ZYD00162 Location: San Antonio TX Duration: Skills: 4 + years in a programmer / analyst capacity with FileNET imagine processing, Content Services, Panagon Capture, IDM Desktop, and Workflow application software and hardware. Business systems and related computer applications, with heavy...

US-TX-Houston: Java Developers, J2EE, XML, OOA/OOD, UML, C++/C#, API's; DH (45325957609)
US-TX-Houston: Java Developers, J2EE, XML, OOA/OOD, UML, C++/C#, API's; DH (45325957609) ======================================================================================== Position: Java Developers Reference: SMC01709 Location: Houston TX Duration: DH Skills: Strong server-side Java experience (e.g. J2EE, XML, Struts, JSP, HTML, etc.). 5-7ys of Application Development work experience. Prior experience in OOA/OOD, Design Patters, UML. Prior experience with team-based development following a ...

Reading Data From An XML File
Since this obviously changes over time what is currently the most effective way to read parts of am XML file?Thanks!! mich schrieb:> Since this obviously changes over time what is currently the most effective > way to read parts of am XML file?> > > Thanks!! > > The SAX parser is up to date and one of the current best parsing solutions when XML streams are analyzed with saving heap.http://sax.sourceforge.net/regardsTorsten Jenkner On Jul 27, 4:27 pm, "mich" <s...@doo.what> wrote:> Since this obviously changes over time what is currently the most effecti...

java
Do any of you know someone experienced in Java that is interested in a full time job in Tucson, Omaha or Dallas? Company dies not pay relo but has an excellent reputation as a great place to work. If you are interested sheck out www.retaliz.com ...

Isn't java.lang.Character.html#{ isLetterFromLang(int codePoint, String ISOLangDef) missing from the spec?
~ One possibly (and easily ;-)) could based on the Unicode code points check the ranges for each language, but I think it would be very useful for people parsing text from different languages. ~ Do you know of any java packages to address these NLP issues? or, if you don't, is there something like that for text processing in ANSI C or C++? ~ Thanks lbrtchx On 04-12-2010 19:16, lbrtchx@gmail.com wrote: > One possibly (and easily ;-)) could based on the Unicode code points > check the ranges for each language, but I think it would be very useful > for people pa...