Results 1 to 9 of 9
Thread: Issue with XML Parsing
- 09-23-2010, 05:14 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 2
- Rep Power
- 0
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.
- 09-24-2010, 12:25 AM #2
Member
- Join Date
- Mar 2010
- Location
- Hilton Head, SC
- Posts
- 34
- Rep Power
- 0
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.
- 09-24-2010, 08:52 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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.
- 09-24-2010, 10:23 AM #4
Member
- Join Date
- Sep 2010
- Posts
- 2
- Rep Power
- 0
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#####
- 09-24-2010, 10:43 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
You have spaces in the tag names.
Or is that merely some example?
- 09-24-2010, 11:33 AM #6
Member
- Join Date
- Mar 2010
- Location
- Hilton Head, SC
- Posts
- 34
- Rep Power
- 0
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.
- 09-24-2010, 11:48 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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.
- 09-24-2010, 08:38 PM #8
Member
- Join Date
- Mar 2010
- Location
- Hilton Head, SC
- Posts
- 34
- Rep Power
- 0
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.
- 09-25-2010, 12:35 PM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
How To Parsing XMI?
By rauff in forum XMLReplies: 11Last Post: 07-07-2010, 04:16 AM -
help with parsing
By ace_03 in forum New To JavaReplies: 15Last Post: 11-24-2009, 09:02 PM -
Parsing XML
By virvalid in forum Advanced JavaReplies: 3Last Post: 08-10-2009, 12:40 PM -
Parsing
By Matt Sakko in forum New To JavaReplies: 14Last Post: 03-21-2009, 04:49 PM -
Parsing URL
By Java Tip in forum Java TipReplies: 0Last Post: 12-26-2007, 10:16 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks