• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

reading web.xml by XPATH

 
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys ,

i'm new to XPATH , i'm trying to read a copy of the web.xml named testweb.xml , but i didnt get any results , only the program prints "for done " and nothing else , here is my code


anything i;m missing ?
 
Ranch Hand
Posts: 466
1
IntelliJ IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sherif,

Please correct your subject. I think you wanted to write web.xml.

Further below XPathExpression does not seems to be right..



Please go through this for clarity on XPATH.
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vinod Tiwari wrote:Hi Sherif,

Please correct your subject. I think you wanted to write web.xml.

Further below XPathExpression does not seems to be right..



Please go through this for clarity on XPATH.



Hi , i cant find anything wrong ...
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All that means is that the XPath expression you chose doesn't select any nodes from the document. One would have to look at the document to see why not. And right now, you're the only one who can do that. We can't see it from here.
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:All that means is that the XPath expression you chose doesn't select any nodes from the document. One would have to look at the document to see why not. And right now, you're the only one who can do that. We can't see it from here.



Sorry You are right Paul , i forget to post the web.xml file , here is the part that i wanna get from the xml file
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Clearly your first error is that the XPath expression is looking for a "wep-app" element as the root, whereas the root of that document is a "web-app" element.

But you're going to come back and tell me that was just a typing error when you made the post, the actual code does say "web-app". Then your problem is that all of your document is in the default namespace, whereas an XPath expression specifying an element name with no prefix is looking for elements with no namespace.

You can fix that by creating a namespace context which assigns the prefix "x" to the namespace URI "http://java.sun.com/xml/ns/javaee", and assigning that namespace context to your XPath object. Then change the XPath expression to "/x:web-app/x:context-param/x:param-name".
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yhanks for your fast reply , do you mean putting this and it will be like this then the XPATh expression object will be like this

Am i right ?
 
Paul Clapham
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.

If I was going to suggest changing the XML document, I would have suggested just getting rid of the default namespace declaration. But I didn't suggest changing the XML document at all, because for all I know changing it would break something. What gave you that idea?
 
Vinod Tiwari
Ranch Hand
Posts: 466
1
IntelliJ IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your xpath should be something like where i=1,2,...
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic