Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Processing XML with Java question  RSS feed

 
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
As I am trying to compile and run examples in "Processing XML with Java" as part of preperation, I am stuck at DOMSpider program in book. Can anyone please explain on why it is occuring? Thanks.

The example am working on is DOMSpider shownhere

When run against site given there i.e. "http://www.rddl.org/" am getting following exception.

java.lang.NullPointerException
at org.apache.crimson.tree.ElementNode2.getAttributeNodeNS(ElementNode2.
java:432)
at org.apache.crimson.tree.ElementNode2.getAttributeNS(ElementNode2.java
:409)
at DOMSpider.isSimpleLink(DOMSpider.java:144)
at DOMSpider.findLinks(DOMSpider.java:93)
at DOMSpider.findLinks(DOMSpider.java:116)
at DOMSpider.findLinks(DOMSpider.java:116)
at DOMSpider.spider(DOMSpider.java:52)
at DOMSpider.main(DOMSpider.java:165)

The relevant code is..

Line where program breaks is
<link href="xrd.css" type="text/css" rel="stylesheet"/>

I could not understand why program breaks at this link element. Is it because of "type" attribute which we are actually trying to retrieve in program and check for "simple" link type or is it because of other reason?

Any input is greatly appreciated.

Thanks,
Satish.
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The getAttributeNS() method in Element interface returns "The Attr value as a string, or the empty string if that attribute does not have a specified or default value."

So is the exception thrown if we have a attribute and if that does'nt belong to namespace specified in method?

Thanks,
Satish.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!