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:
<Name>John</Name>
<Folder>C:\John</Folder>
<Time>12:30</Time>

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
"<Name>John</Name><Time>12:30</Time>"

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.

Thanks

Recommended Answers

All 5 Replies

String sre="fd\fd\trt";
String dsa=sre.replaceAll("'\'", "'\\'");

No help whatsoever.

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

actually, his advice worked :)

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.