Results 1 to 9 of 9
  1. #1
    Vishnu7185 is offline Member
    Join Date
    Sep 2010
    Posts
    2
    Rep Power
    0

    Default Issue with XML Parsing

    My process is returning an xml in the form of a string.I need to parse this XmlString and pull the values in it.

    <Outer Tag
    Data 1="wewe"
    Data 2="1"
    Data 3 ="13 Oct 2006"
    Data 4="Sample">
    <First Inner>
    <First Inner. Inner 1
    Data 1="28310615"
    Data 2="Sample333"
    Data 3 ="######Sample33###########hujjj#####">
    </First Inner. Inner 1>
    </First Inner>
    </Outer Tag>

    This is the sample xml.

    I wanted to parse this string and pull out ######Sample33###########hujjj#####

    which Parser should i be using and how? Since the xml is not well formed(may be i am unaware) i am stuck.

    I tried with SAXParser but i am getting the following error
    org.xml.sax.SAXParseException: Content is not allowed in trailing section.

  2. #2
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default

    That 'technically' isn't XML since it doesn't contain all of the necessary elements of an XML document. Perhaps you should learn XML first so you know how to create a well-formed document: XML Tutorial

    As for a parser, it would depend on the application and the constraints you are working with but the easiest to use would be the DOM parser. If you are familiar with the DOM in web dev then it should be a snap to use.

  3. #3
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,448
    Rep Power
    18

    Default

    Yep, in fact nothing technical about it. It's not xml, so you can't parse it using any sort of xml parser. '<' and '>' does not xml make.

  4. #4
    Vishnu7185 is offline Member
    Join Date
    Sep 2010
    Posts
    2
    Rep Power
    0

    Default

    Hi

    The xml had the top tags like the xml version and DOCTYPE which i have removed.

    I tried using an XSLT processor and it worked. But I am encountering another issue when my out put i am trying to convert into an Json Array
    ######Sample33###########hujjj#####

  5. #5
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,448
    Rep Power
    18

    Default

    You have spaces in the tag names.
    Or is that merely some example?

  6. #6
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default

    Your tags are also supposed to be in lower case <TAG STUFF=""> is not acceptable. Like I said, you must go over that tutorial and learn what you can and cannot do with XML.

  7. #7
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,448
    Rep Power
    18

    Default

    Are they?
    Didn't think the spec precluded that?
    They definition for a Name doesn't anyway.

    Is that just a form of xml coding standard?

    A lot of xml is camel cased, especially xsds for web services which get turned into Java classes.

  8. #8
    67726e is offline Member
    Join Date
    Mar 2010
    Location
    Hilton Head, SC
    Posts
    34
    Rep Power
    0

    Default

    I'm not actually sure about the 'names'. I mean I have always done it and everyone I know does it. I also know the XHTML spec states they must do that and the XHTML standard was made to make websites XML compliant.

  9. #9
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,448
    Rep Power
    18

    Default

    Well, I think the XHTML is like that because XML is case sensitive, and they defined the various tags as lower case. Then again, they're usually single words, or abbreviations.

    If you look at web services you'll usually see camel case (to match Java, or other, naming conventions)

Similar Threads

  1. How To Parsing XMI?
    By rauff in forum XML
    Replies: 11
    Last Post: 07-07-2010, 04:16 AM
  2. help with parsing
    By ace_03 in forum New To Java
    Replies: 15
    Last Post: 11-24-2009, 09:02 PM
  3. Parsing XML
    By virvalid in forum Advanced Java
    Replies: 3
    Last Post: 08-10-2009, 12:40 PM
  4. Parsing
    By Matt Sakko in forum New To Java
    Replies: 14
    Last Post: 03-21-2009, 04:49 PM
  5. Parsing URL
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-26-2007, 10:16 AM

Posting Permissions

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