Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Incompatible Types using DOMParser getDocument

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Thanked 0 Times in 0 Posts

    Default Incompatible Types using DOMParser getDocument

    Hello. I'm receiving the following exception when calling the getDocument method. We have included the proper jar file, so I'm not sure why this error is occurring. Thanks in advance for the assistance.

    The specific error is:

    java:85: error: incompatible types
    doc = parser.getDocument();

    required: org.dom4j.Document
    found: org.w3c.dom.Document
    1 error

    The relevant code:
    import org.dom4j.Document;
    import org.dom4j.DocumentHelper;
    import org.dom4j.Element;
    import org.dom4j.Node;
    import org.apache.xerces.parsers.DOMParser;

    DOMParser parser = new DOMParser();
    org.dom4j.Document doc;
    parser.parse(new InputSource(new StringReader(s_xml)));
    doc = parser.getDocument();

  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    My Mood
    Thanked 140 Times in 135 Posts

    Default Re: Incompatible Types using DOMParser getDocument

    I've not used dom4j, but doesn't it have its own parser, one that will return an org.dom4j.Document?

Similar Threads

  1. [SOLVED] Referencing to Method. Incompatible Types Error.
    By mwebb in forum Object Oriented Programming
    Replies: 12
    Last Post: February 5th, 2012, 03:50 PM
  2. incompatible types!!
    By sneha343 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 30th, 2011, 05:48 PM
  3. incompatible types
    By frozen java in forum What's Wrong With My Code?
    Replies: 3
    Last Post: January 25th, 2011, 10:40 AM
  4. incompatible types Exception
    By world.java in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 17th, 2010, 01:33 PM
  5. Incompatible Types
    By Kimimaru in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 28th, 2010, 09:52 AM