Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escape double quote character in XML

Tags:

xml

escaping

Is there an escape character for a double quote in xml? I want to write a tag like:

<parameter name="Quote = " "> 

but if I put ", then that means string has ended. I need something like this (c++):

printf("Quote = \" "); 

Is there a character to write before the double quote to escape it?

like image 339
ufukgun Avatar asked Aug 03 '09 13:08

ufukgun


People also ask

How do you escape special characters in XML?

XML escape characters There are only five: " &quot; ' &apos; < &lt; > &gt; & &amp; Escaping characters depends on where the special character is used. The examples can be validated at the W3C Markup Validation Service.

Are double quotes allowed in XML?

xml Escaping Apostrophes and quotesAttribute values can appear in simple or double quotes. The appropriate character must be escaped.

How do you use double quotes in double quotes in XML?

From the XML specification: To allow attribute values to contain both single and double quotes, the apostrophe or single-quote character (') may be represented as "&apos;", and the double-quote character (") as "&quot;".


2 Answers

Try this:

&quot; 
like image 57
Andrew Hare Avatar answered Sep 24 '22 07:09

Andrew Hare


Here are the common characters which need to be escaped in XML, starting with double quotes:

  1. double quotes (") are escaped to &quot;
  2. ampersand (&) is escaped to &amp;
  3. single quotes (') are escaped to &apos;
  4. less than (<) is escaped to &lt;
  5. greater than (>) is escaped to &gt;
like image 29
Alex Muriithi Avatar answered Sep 26 '22 07:09

Alex Muriithi