1

I was sending xml parameter to rest service like below

<Envelope xmlns="http://w3gana/2003/05/soap-envelope">
<Header>
<To xmlns="http://www.w3.svc</To>    
</Header>
<Body>
<tns:RetRES>
  <tns:EmpDef>        
        <studyChar>
          <I2:code code="QA Last" />
          <I2:value value="BDA & MAST" />
        </studyChar>         
    </I2:planStd>
  </tns:EmpDef>
 </tns:RetRES>
</Body>
</Envelope>

It was throwing error like "there is an unclosed literal string line 1", but it was accepting alphabets.

I have tried following strings instead of & but still i'm getting the same error.

& & & & &

Please help to resolve this

Rajan
  • 71
  • 1
  • 6
  • Have you tried escaping them like `\&` or use character data like `<![CDATA['&']]>` – choz Nov 17 '15 at 02:33

4 Answers4

2

I think what you might be looking for is this: &amp

You can use that in place of & when coding in XML, certain charaters are illegal to use in XML such as <, and >.

Julio
  • 153
  • 6
0
<To xmlns="http://www.w3.svc</To> 

Aren't you missing the quotes after the url

<To xmlns="http://www.w3.svc"</To> 

IF not then follow this link How do I escape ampersands in XML so they are rendered as entities in HTML?

Community
  • 1
  • 1
Bug Hunter 219
  • 312
  • 1
  • 14
0

You might have forgotten to close your To tag

<To xmlns="http://www.w3.svc"></To>

If it doesn't fix it, you might want to try to escape it.

<I2:value value="BDA \& MAST" />

or

<I2:value value="BDA &amp; MAST" />

or

<I2:value value="BDA %26amp; MAST" />
0

If you're asking how to escape an ampersand, have you tried. &amp;?

Also, you didn't close your To tag... it's missing a quote and the bracket.

b.pell
  • 3,873
  • 2
  • 28
  • 39