0

How can I apply CDATA here in such XML of web services in asp.net, as in

<booktitle> data </booktitle>

I have some symbols like '&', which resist me to parse it to Android.

Here is my code:

for (int iBookResponse = 0; iBookResponse < dataTable.Rows.Count; iBookResponse++)
                {
                    DataRow dataRow = dataTable.Rows[iBookResponse];

                    xmlResponse += "<Book>";
                    xmlResponse += "<BookID>" + dataRow["book_id"].ToString() + "</BookID>";
                    xmlResponse += "<BookCode>" + dataRow["book_code"].ToString() + "</BookCode>";
                    xmlResponse += "<BookTitle>" + dataRow["book_title"].ToString()+ "</BookTitle>";
                   xmlResponse += "</Book>";

        }
halfer
  • 19,824
  • 17
  • 99
  • 186
Qadir Hussain
  • 8,721
  • 13
  • 89
  • 124

1 Answers1

0

Just prepend xmlResponse with <![CDATA[ and append ]]> to it. So your xmlResponse can start with

xmlResponse += "<![CDATA[<Book>";

and end it with

  xmlResponse += "</Book>]]>"

with everything else in between.

kolossus
  • 20,559
  • 3
  • 52
  • 104