Re: [xsl] Escaping data in XML attributes

Subject: Re: [xsl] Escaping data in XML attributes
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Sat, 09 Feb 2008 16:01:11 +0100
Robert La Ferla wrote:

Let's say that my database returns this XML unfriendly name that I need to insert into an XML document.

"Bob's Black & Tan "Boston Branch <1>"


Is there a way I can still use attributes yet escape these unsavory characters? What's the most efficient way of solving this?

You need to escape the ampersand as &amp;, the double quote as &quot;, the less-than as &lt; and the greater-than as &gt;.
Use an API that does the escaping for you, for instance with the .NET framework there is XmlWriter.




--

	Martin Honnen
	http://JavaScript.FAQTs.com/

Current Thread