473,326 Members | 2,134 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,326 software developers and data experts.

The "replaceAll" method of the String Class can't work, if a "?" character is in the value of an attribute of a XMLString!

Ed
Hi All,

The sample code below doesn't work, but if you take out the Question
Mark character, "?" in front of the value "Print" of the "action"
attribute, it does work!

Does anyone here know an other workaround? Thanks in advance!
////////////////////////////////////////////////////////////Sample
code ////////////////////////////////////////////////////////
public class Questionmark_TEST{

public Questionmark_TEST(){}
public static void main(String [] args){
String XMLString="<?xml version=\"1.0\" encoding=\"UTF-8\"?
><categories><NodeOne action='Print?'/></categories>" ;
String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";
XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());

}

}
//////////////////////////////////////////Sample
code ///////////////////////////////////////////////////////////////////////////////////////////////

Sep 13 '07 #1
12 2180
Ed


Hi All,

The sample code below doesn't work, but if you take out the Question
Mark character, "?" in front of the value "Print" of the "action"
attribute, it does work!
Does anyone here know an other workaround? Thanks in advance!

///////////Sample code //////////////////

public class Questionmark_TEST{
public Questionmark_TEST(){}
public static void main(String [] args){
String XMLString="<?xml version=\"1.0\" encoding=\"UTF-8\"?
><categories><NodeOne action='Print?'/></categories>" ;

String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";

XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());

}
}

///////Sample code /////////////////

Sep 13 '07 #2
Lew
Ed wrote:
The sample code below doesn't work, but if you take out the Question
Mark character, "?" in front of the value "Print" of the "action"
attribute, it does work!

Does anyone here know an other workaround? Thanks in advance!
You need to watch where line breaks go in source posts to Usenet. You got a
stray greater-than character ('>', a.k.a., "right angle bracket") that
belonged with the xml PI, but was somehow moved to a different line.

Also, the variable "XMLString", being a variable, should start with a
lower-case letter, by convention.
public class Questionmark_TEST{
public Questionmark_TEST(){}

public static void main(String [] args){
String XMLString =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+
"<categories><NodeOne action='Print?'/></categories>";

String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";

XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());
}
}
Did you read the Javadocs on the replaceAll() method?
<http://java.sun.com/javase/6/docs/api/java/lang/String.html#replaceAll(java.lang.String,%20java.la ng.String)>

The first argument is a regular expression, in which the question mark has
special significance.

--
Lew
Sep 13 '07 #3
Ed
On Sep 12, 11:35 pm, Lew <l...@lewscanon.comwrote:
Ed wrote:
The sample code below doesn't work, but if you take out the Question
Mark character, "?" in front of the value "Print" of the "action"
attribute, it does work!
Does anyone here know an other workaround? Thanks in advance!

You need to watch where line breaks go in source posts to Usenet. You got a
stray greater-than character ('>', a.k.a., "right angle bracket") that
belonged with the xml PI, but was somehow moved to a different line.
Come on, dude! Are you so stupid, to not understand that the code
works, and you may need to move the bracket, where it supposes to be,
when running it!
>
Also, the variable "XMLString", being a variable, should start with a
lower-case letter, by convention.
Where did you get that rule, Mr. Conformist!
Don't lecture to anyone here, your nonsense rule! Try to think out of
the box sometime!

public class Questionmark_TEST{
public Questionmark_TEST(){}
public static void main(String [] args){
String XMLString =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+
"<categories><NodeOne action='Print?'/></categories>";
String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";
XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());
}
}

Did you read the Javadocs on the replaceAll() method?
<http://java.sun.com/javase/6/docs/api/java/lang/String.html#replaceAl...)>

The first argument is a regular expression, in which the question mark has
special significance.
But you never answered my question though! Take a look what Roedy
replied to me! That's kind of an answer, I was looking for!
Sep 13 '07 #4
On Sep 13, 3:27 pm, Ed <aru...@yahoo.comwrote:
On Sep 12, 11:35 pm, Lew <l...@lewscanon.comwrote:
Ed wrote:
The sample code below doesn't work, but if you take out the Question
Mark character, "?" in front of the value "Print" of the "action"
attribute, it does work!
Does anyone here know an other workaround? Thanks in advance!
You need to watch where line breaks go in source posts to Usenet. You got a
stray greater-than character ('>', a.k.a., "right angle bracket") that
belonged with the xml PI, but was somehow moved to a different line.

Come on, dude! Are you so stupid, to not understand that the code
works, and you may need to move the bracket, where it supposes to be,
when running it!
Also, the variable "XMLString", being a variable, should start with a
lower-case letter, by convention.

Where did you get that rule, Mr. Conformist!
Don't lecture to anyone here, your nonsense rule! Try to think out of
the box sometime!
public class Questionmark_TEST{
public Questionmark_TEST(){}
public static void main(String [] args){
String XMLString =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+
"<categories><NodeOne action='Print?'/></categories>";
String OldNode = "<NodeOne action='Print?'/>";
String NewNode = "<NodeOne action='Print?'>empty</NodeOne>";
XMLString = XMLString.replaceAll(OldNode,NewNode);
System.out.println("new XMLString : "+XMLString.toString());
}
}
Did you read the Javadocs on the replaceAll() method?
<http://java.sun.com/javase/6/docs/api/java/lang/String.html#replaceAl...)>
The first argument is a regular expression, in which the question mark has
special significance.

But you never answered my question though! Take a look what Roedy
replied to me! That's kind of an answer, I was looking for!
Tsk.

Lew's reply contain the same information as Roedy's post. To be fair,
Lew's reply contains *more* information than Roedy's. Lew notified
you, politely, about the use of regular expression in
String.replaceAll(), netiquette of using usenet, and globally accepted
Java coding convention, while Roedy simply pointed you to what you
need without much explanation (nothing wrong with Roedy's answer...
but you won't really learn why unless you act by going to his site and
read).

And you chose to thank Roedy and spit in Lew's face.

Sep 13 '07 #5
Quick reminder to all: This is a good time to review
http://catb.org/~esr/faqs/smart-questions.html
.... and to remember that when someone's getting excessively angry,
arguing with them is generally not going to improve matters.

(Killing the thread.)

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Sep 13 '07 #6
Ed wrote:
On Sep 12, 11:35 pm, Lew <l...@lewscanon.comwrote:
>Also, the variable "XMLString", being a variable, should start with a
lower-case letter, by convention.

Where did you get that rule, Mr. Conformist!
From Sun's Java Coding Convention, which you should study.

Arne
Sep 14 '07 #7
Ed wrote:
On Sep 13, 2:08 am, kcwong <evilwar...@gmail.comwrote:
>To be fair,
Lew's reply contains *more* information than Roedy's.

I don't need more info! If I need more info, I could have spent hours
surfing the internet, and reading all about the String class and the
XML specification.
I am not a Student and don't have a time, I am a Programmer, and
wanted to resolve my current task!
Why ?

If you are not able to lookup some methods in the Java API docs
quicker than posting to usenet, then there are no point in
writing any code - the result should go directly to the trash bin.

Arne
Sep 14 '07 #8
Ed
On Sep 13, 5:14 pm, Arne Vajhøj <a...@vajhoej.dkwrote:
Ed wrote:
On Sep 13, 2:08 am, kcwong <evilwar...@gmail.comwrote:
To be fair,
Lew's reply contains *more* information than Roedy's.
I don't need more info! If I need more info, I could have spent hours
surfing the internet, and reading all about the String class and the
XML specification.
I am not a Student and don't have a time, I am a Programmer, and
wanted to resolve my current task!

Why ?

If you are not able to lookup some methods in the Java API docs
quicker than posting to usenet, then there are no point in
writing any code - the result should go directly to the trash bin.

Arne
That is your opinion, jackass!

Sep 14 '07 #9
On Sep 14, 1:34 pm, Ed <aru...@yahoo.comwrote:
<snip endless stream of uncalled for insults from Ed>

At this point, one has to wonder that if Ed really has a question to
ask, or is he started this thread just to troll.

In any case I don't think Ed will get any more answers from this group.

Sep 14 '07 #10
Ed wrote:
For your info, you may even be using a Java IDE Compiler written by my
friends!
What is a "Java IDE Compiler". Sounds very interesting. It it a compiler
that generates Java IDE's from meta language or is it a compiler that
generates any IDE from meta language using a compiler written in Java ?

Arne
Sep 15 '07 #11
Reminder: Feeding trolls only encourages them.

If you're gonna continue to argue with Ed, I strongly suggest you take
it to e-mail, or at least limit it to one newsgroup rather than pissing
in *two* communities' swimming pools.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Sep 16 '07 #12
Joshua Cranmer wrote:
In answer to your last question, perusing his headers indicates that Mr.
Pitts is using an en-US-localized Firefox build, therefore it is safe to
assume that he is working in the US.
I would not assume that.

A lot of people outside the US prefer to run UK or US versions of
all software.

Arne
Sep 16 '07 #13

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

Similar topics

0
by: Binu jose | last post by:
Hi all i am trying to replace a char sequence starting with -- and ending with \r\n using String.replaceAll() function. How will be the regular expression for that. Thanks Binu Jose
5
by: Andrew Dixon - Depictions.net | last post by:
Hi Everyone. I have been working on some code that strips the HTML code out of an HTML page leaving just the text on the page. At the moment this is what I have: // Strip all tags...
8
by: Frank Ratzlow | last post by:
Hi folks, I have a list of entries where some entries contain the special character (quotes) within in the string. If I try to save this entry everything after the quotes is skipped. The reason...
2
by: Eric Osman | last post by:
Hi, I'm looking for a javascript function that will convert input such as this: <CLUB Code=" into this: &lt;CLUB Code=&quot;
2
by: judge82 | last post by:
i keep getting that error on line 139. i need help please * RegLoginServletHW3.java * * Created on October 17, 2007, 10:29 PM */ package ITIS5166;
2
by: getmeidea | last post by:
Hi all, String x = "\\"; This string will have the value \. Now for any string contains \, i need to replace with \\. But when i use x = x.replaceAll("\\", "\\\\"); I am getting runtime...
8
by: bsonline | last post by:
I want to replace + sign with 2 blackslash and 1 + sign (\\+)... when I use the replaceAll()... It throws a 500 status error like "java.util.regex.PatternSyntaxException: Dangling meta character...
3
by: chriskaza81 | last post by:
helo all i have a string blablabla""blabla"" i want to make a space between two double qoates like blablabla" "blabla" " how can i do it in java .. i use replaceAll ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.