• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 783
  • Last Modified:

Need help to declare String variable in Java

I have String variable to declare.Input value is  XML data  and i want to declare it as string. but  iyt is giving syntax error :i have put dounle quotes between string.
Here is  String declaration:
String xmlData="<?xml version="1.0" encoding="utf-8"?><resellerOrder xmlns="http://www.verizonwireless.com/oas" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.verizonwireless.com/oas http://durbdd02.ddc.vzwcorp.com:8085/schema/reseller.xsd"> <messageHeader>  </messageHeader> <order>  <orderTimeStamp>01/05/2002 00:00:00</orderTimeStamp>  <accountNumber>1123</accountNumber>  <subOrder>  </subOrder> </order></resellerOrder>"};
0
ANISHKA1
Asked:
ANISHKA1
  • 2
1 Solution
 
ksivananthCommented:
you need to escape the double quotes!

for e.g.,

" should be replaced with \"
0
 
ANISHKA1Author Commented:
Thanks.
0
 
ksivananthCommented:
try this,

String xmlData = "<?xml version=\"1.0\" encoding=\"utf-8\"?><resellerOrder xmlns=\"http://www.verizonwireless.com/oas\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.verizonwireless.com/oas http://durbdd02.ddc.vzwcorp.com:8085/schema/reseller.xsd\"> <messageHeader>  </messageHeader> <order>  <orderTimeStamp>01/05/2002 00:00:00</orderTimeStamp>  <accountNumber>1123</accountNumber>  <subOrder>  </subOrder> </order></resellerOrder>" ;
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now