473,382 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Extra Lines inserted for Special Characters (&)

My parser parses special characters okay, but adds extra line breaks.
It makes no sense to me at all! If anyone knows what I am doing wrong,
please help.

text file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Feed SYSTEM "SDF_NA4.dtd">
<Feed>
.....
<OfficialName>Great Big &amp; Little Co.</OfficialName>
........
I use java SAXParserFactory (variable name = factory):
factory.setValidating(true);

and when I call convertElement(String) on this line, it reads it 3
times!
1st the code:
public void convertElement(String elementValue) throws SAXException
{
if (eName.equals("OfficialName")) {
company.setOfficalName(elementValue);
tempCounter++;
System.out.println("counter=" + tempCounter + " -->" +
elementValue);
char offName[] = elementValue.toCharArray();
for (int i = 0; i < offName.length; i++) {
System.out.println(offName[i]);
}
2nd the output:
<?xml version='1.0' encoding='UTF-8'?>counter=1 -->Great Big
G
r
e
a
t

B
i
g

counter=2 -->&
&
counter=3 --Little Co.

L
i
t
t
l
e

C
o
..
Can anyone help!?

Thank you
Lonni

Jan 24 '07 #1
2 1995
Remember, SAX does not promise that all contiguous text will be
delivered as a single call to characters() -- and entity references are
one of many things which will cause it to be divided up.

If you want a single contiguous string, your app is responsible for
buffering the characters() events until it sees something else, and then
processing the result.
Jan 24 '07 #2


On Jan 24, 10:26 am, Joseph Kesselman <keshlam-nos...@comcast.net>
wrote:
Remember, SAX does not promise that all contiguous text will be
delivered as a single call to characters()
Thank you, I didn't realize that!

I will change my code appropriately.

Lonni

Jan 24 '07 #3

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

Similar topics

4
by: Sidharta | last post by:
Hi all, how come this doesn't work????? # convert to unix new lines $text = preg_replace("/\r\n/", "\n", $text); # remove extra new lines $text = preg_replace("/\n+/", "\n", $text); is...
4
by: Krishna A.M | last post by:
Hi, How do i add a hyperlink to a email id having special characters? I tried the same , say mailto: test_&_send@hoohoo.com IN the to box i can see only till test_ and the rest is omitted. ...
5
by: Jamie Jackson | last post by:
Two fairly basic questions: I need to supply a method with an array of strings, which will eventually be used to pattern match against another array of strings. 1. Is there a good way to span...
2
by: Thierry Lam | last post by:
Let's say I have the following xml tag: <para role="source">a & b</para> Currently, an xml parser will treat & as a special character. Does anyone know the special characters to use around...
2
by: GSK | last post by:
I'm using System.Web.Mail to send HTML formatted e-mails, and something very bizarre is happening. When I send a message to myself, it looks fine, but when my client sends one to herself, she...
1
by: Robert Dodier | last post by:
Hello, Sorry for asking what must be a FAQ, but I wasn't able to find the answer. I have an XML document fragment which I want to store as a text string. I want a function to convert any XML...
2
by: ricky | last post by:
Can anybody help with the function to get rid of extra characters in the file. I want to remove the string from the file.So i read from input file and pass the string say "john" if found dnt write...
25
by: Wim Cossement | last post by:
Hello, I was wondering if there are a few good pages and/or examples on how to process form data correctly for putting it in a MySQL DB. Since I'm not used to using PHP a lot, I already found...
3
by: webqueen79 | last post by:
When I open up my asp code in an editor, I see TONS of extra whitespace between code lines which is making the editor bomb out because it takes so long to load all the lines. When I open up the asp...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.