I’m using kXML in my Blackberry application using Java. I want to create a string that has the xml information I need for testing purposes.
Any guidance?
For example:
String theXML = @"
<xml>
</xml>";
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no easy answer. You need to represent it as a regular Java String literal with backslash escaping for tabs, newlines, double quotes, backslashes and so on.
Your IDE may offer you some support in adding the escaping. Otherwise, you may need to do it by hand.
My advice is that if you have a lot of XML you’d be better off reading it from a file instead of embedding it in your Java code, or (as @Thilo reminds me) putting it in a resource that you can access using
Class.getResourceAsStream(path)