• 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

Extracting attributes from xml with xpath

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am trying to extract the attributes from the follwing xml but it does not work.

Any suggestion what I am doing wrong.


My xml



The code I use:



 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You said it does not work but failed to indicate the error messages received and provided very little code. That said, I can see a possible problem or two from the little info you did provide.
At I think you really want XPathExpression
In the call to

you are passing the interface Document instead of the reference to document.
You're trying to do something with emailNodes when you probably mean phoneNodes.
And I don't believe there is a getAttribute(String) method on the Node API You probably want something more like


Have another read on th API. Hope this didn't give away a homework assignment.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is


shouldn't it be



... Also post error if you are facing any
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'll move this to our XML forum.
 
thomas colding
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote:I'll move this to our XML forum.



Correct my mistake, I was to fast posting the answer
 
thomas colding
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ed Ward wrote:You said it does not work but failed to indicate the error messages received and provided very little code. That said, I can see a possible problem or two from the little info you did provide.
At I think you really want XPathExpression
In the call to

you are passing the interface Document instead of the reference to document.
You're trying to do something with emailNodes when you probably mean phoneNodes.
And I don't believe there is a getAttribute(String) method on the Node API You probably want something more like


Have another read on th API. Hope this didn't give away a homework assignment.



Yes I should, Is it API for XPath.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi thomas colding,

Do you know how to extract the attributes for the next element:



I have tried through with various ways, but I have no received the expected results.

Some suggestions? Thanks in advance.

So long!
 
reply
    Bookmark Topic Watch Topic
  • New Topic