473,509 Members | 2,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SAX Parsing - Weird results when parsing content between tags.

I have an XML like the one below.

I am using SAX parsing and I need to get the information between the
tags of the Email element. First i try to access the content and print
it out and it gives me weird results.

XML:
/www.xmlspy.com) by AB(Co) --><!--Sample XML file generated by XML Spy
v4.0.1 U (http://www.xmlspy.com)-->
<RoomResRQ xmlns:commonelements="http://*.com/schema/CommonElements"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
Action="CreateNew">

<RoomResSpecs>
<RoomResSpec>
<RoomResParty>
<PartyMixInfo>
<Email>
na**********@yahoo.com
</Email>
</PartyMixInfo>
</RoomResParty>
</RoomResSpec>
</RoomResSpecs>
</RoomResRQ>
The RESULT of running my parser on this is:

/www.xmlspy.com) by AB(Co) --><!--Sample XML file generated by XML Spy
v4.0.1 U (http://www.xmlspy.com)-->
<RoomResRQ xmlns:commonelements="http://*.com/schema/CommonElements"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
Action="CreateNew">

<RoomResSpecs>
<RoomResSpec>
<RoomResParty>
<PartyMixInfo>
<Email>
na**********@yahoo.com

I expect only the email address to be output, but everything else
before the address is also printed.
I appreciate if anyone can help.
In startelement(), I have the following condition for email.
if (localName.equals(Email)
{
readyForContent = true;
}
In the characters() method, I read the content only when the
readyForContent flag is true. In the endElement() method, I first set
the readyForContent flag to true.
So, The content is read only when the flag is true and it happens only
when the startElement is Email.

public void characters(char[] ch, int start, int length)
throws SAXException {

if (readyForContent)
{
emailBuf = new StringBuffer();
emailBuf.append(ch, start, length);
System.out.println(emailBuf);

}
}
public void endElement(String namespaceURI, String localName, String
qName)
throws SAXException {
readyForContent = false;
//clean the stack
if (!tagStack.isEmpty()){
tagStack.pop();
}
}
Jul 20 '05 #1
0 1537

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
5724
by: Hostile17 | last post by:
Consider the following HTML. ---------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <meta...
11
13657
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
10
1604
by: Kathy Burke | last post by:
Hi, in trying to discover why my RegisterStartUpScript wouldn't work (I do NOT see it in the HTML source), I looked at the HTML source of a page where I do an XslTransform. First, I get the...
13
1618
by: guitarromantic | last post by:
Hey everyone. I'm editing some stuff I did last summer, trying to bugfix and improve stuff. One improvement (or an oversight of the original design) is adding dynamic <title> tags to my pages....
1
2413
by: yonido | last post by:
hello, my goal is to get patterns out of email files - say "message forwarding" patterns (message forwarded from: xx to: yy subject: zz) now lets say there are tons of these patterns (by gmail,...
9
4042
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
5
1423
by: timslavin | last post by:
Hi, I'm trying to do something with PHP and I'm not 100% familiar with PHP as I am with VBScript. So if you could bear with me on what is likely a stupid question, I'd appreciate it! I have a...
8
2173
by: Bob Bedford | last post by:
Hi all, I've to read and parse an XML file to save the datas in a database. Unfortunately it appens that the datas are wrong. I mean it seems they are not well readed...sometimes only part of...
1
2362
by: Stuart Shay | last post by:
Hello All: I am working on parsing the Amazon Key word search webservice for the Editorial Reviews Content containing "Amazon.Com Review" in the Source element. <EditorialReviews>...
0
7347
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.