Results 1 to 6 of 6
  1. #1
    Cylab is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default parse XML tags (urgent)

    I need to read XML data " <a> ball </b>" from a file.
    since it contains error, the output has to be like this.

    ERROR: MISMATCH TAG on line 1: <a> and </b>!

    SOS: how can i write a java code that shows the error massage above.:(
    Any kind of help will highly be appreciated.

    Thanks for your attention.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Cylab View Post
    I need to read XML data " <a> ball </b>" from a file.
    since it contains error, the output has to be like this.

    ERROR: MISMATCH TAG on line 1: <a> and </b>!

    SOS: how can i write a java code that shows the error massage above.:(
    Any kind of help will highly be appreciated.

    Thanks for your attention.
    Use a SAX parser and supply your own DefaultHandler; read the API documentation for the DefaultHandler class; it supplies empty implementations for everything; override the methods you're interested in. The SAX parser calls this default handler at every state of its parse process, also when it has detected a syntax error. I am not going to write the code for you, read the documentation.

    kind regards,

    Jos

  3. #3
    Cylab is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default

    Thanks Jos.
    But Could you please tell me how to display error with line.

    Thanks again

    Ted

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Cylab View Post
    Thanks Jos.
    But Could you please tell me how to display error with line.

    Thanks again

    Ted
    You also informed me (through a PM) that a 'requirement' also forbids an ordinary XML parser to be used. I find that requirement rediculous and can't help you in a decent way anymore; you have to hack your way through it; maybe you can (ab)use regular expressions for the purpose or do everything yourself by reading the XML input 'by hand' or whatever. A decent solution is not possible given that requirement.

    kind regards,

    Jos

  5. #5
    Cylab is offline Member
    Join Date
    Jun 2010
    Posts
    29
    Rep Power
    0

    Default

    You are right Jos. No decent solution for it, I guess, because it is test I was given with deadline, and I am running out of time.

    Could it be possible for you to tell me HOW TO PROMPT ERROR WITH LINE?
    Thanks again.

    Ted

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,344
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Cylab View Post
    You are right Jos. No decent solution for it, I guess, because it is test I was given with deadline, and I am running out of time.

    Could it be possible for you to tell me HOW TO PROMPT ERROR WITH LINE?
    No, I'd have to write at least a rudimentary XML parser for that and I am not going to do that because there already is a complete XML parser at our disposal for those purposes but for some reason you're not allowed to use it (which I find silly). And above all: it is your assignment so you should put at least some effort in it and not rely on others to do your job. Come back with specific questions and we might be able to help.

    kind regards,

    Jos

Similar Threads

  1. How to parse this value
    By Ajitha in forum New To Java
    Replies: 2
    Last Post: 06-03-2010, 07:26 AM
  2. [URGENT]SHA Encryption System...need urgent helps
    By java_idiot in forum New To Java
    Replies: 6
    Last Post: 05-02-2010, 10:04 AM
  3. using parse
    By mustachMan in forum New To Java
    Replies: 2
    Last Post: 01-15-2010, 01:32 AM
  4. SAX Parse
    By bluefloyd8 in forum New To Java
    Replies: 1
    Last Post: 01-25-2008, 03:57 PM
  5. How to parse HTML tags
    By Ada in forum Advanced Java
    Replies: 1
    Last Post: 05-31-2007, 09:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •