Groups | Blog | Home
all groups > dotnet xml > september 2003 >

dotnet xml : List of XPath Escape Characters


Matthew Wieder
9/25/2003 12:02:33 PM
In my previous post, I asked about a routine which prepares a string for
an XPath query by taking care of escape characters.
Unable to find a list, I'm now wondering assumign I enclose the
attribute value in quotes in my XPath query, what other escape
characters need to be handled aside from a quotation mark? As I
understand it, an apostrophe wouldn't be a problem since I'm enclosing
the string in quotes.
thanks!
lukezhan NO[at]SPAM online.microsoft.com
9/26/2003 3:28:02 AM
Hi Matthew,

For a list of these special characters, you may refer to:

HOW TO: Locate and Replace Special Characters in an XML File with Visual
Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;EN-US;308060

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


SQL Server Development Team [MSFT]
9/26/2003 12:57:57 PM
In attribute value you still can not literally use (&), because (&)
indicates the start of entity reference. Instead you must use (&),
Besides, as you already knew, if you want to use inside attribute value,
then you have to pay special attention not to use the one you deliminate the
attribute value. For example, you said you are using quotation (") to
enclose your attribute value, then you must escape it inside the attribute
value, otherwise, the XmlReader or XmlDocument will recognize it as the end
of the attribute value.But you can still use (').

If you want to do preparation for Xml source file, the list of special
characters is here:
Character Name Entity Reference Character Reference Numeric Reference
Ampersand & & &
Left angle bracket &lt; < &#38;#60;
Right angle bracket &gt; > &#62;
Straight quotation mark &quot; " &#39;
Apostrophe &apos; ' &#34;


Among the 5, (>), ("), and (') has been handled by the XmlReader and the
XmlDocument objects because only single character replacement is required
for these characters. The VB code you see on the page from the link in last
email actually don't do much more than escaping (&) and the 2nd (<).

HTH,
Jun Wang

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
[quoted text, click to view]

AddThis Social Bookmark Button