I'm reading a whole xml file in as a string.
Some of the Node values are directories, e.g. "C:\"
When I print out the string, to make sure that the file has been read in correctly, I see that it has completely ignored the Nodes that have directories in them.

As an example, let's say the xml file has these 3 Nodes in it:

When I print out the string that's supposed to read: "<Name>John</Name><Folder>C:\John</Folder><Time>12:30</Time>" it prints out

I tried to escape the \'s like this:

DataLine.replaceAll("\\", "\\\\");

but it throws an exception. I tested the line to see if it actually contained a "\" character ( Dataline.indexOf("\\") ) and it returns -1, meaning that the string does not contain that character.

Can anyone help me with this? I just want the xml string to contain ALL the nodes.


8 Years
Discussion Span
Last Post by P00dle

No help whatsoever.

Why don't you show us your "read" and "print out" code?

Edited by masijade: n/a


actually, his advice worked :)

Definately not using both double quotes and single quotes.

Then again, I have no idea how a replace or not replace would keep that particular string from being printed, especially since you can read and use a single \ when the things are read from a file, so I also need to ask, again, what else you were doing.

All of this, again, would have been cleared up by, showing your code and giving a better description of the actions you're taking.

Edited by masijade: n/a


I understand. Apologies, I will make an effort to be clear about what I am doing and what I'm trying to do.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.