sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
MAF's Avatar

Special Characters


Question posted by: MAF (Guest) on November 12th, 2005 05:08 AM
Is there a quick way to convert all special characters to XML format for
example '&' to & or '+' sign to ? ?


3 Answers Posted
Martin Honnen's Avatar
Guest - n/a Posts
#2: Re: Special Characters



MAF wrote:
[color=blue]
> Is there a quick way to convert all special characters to XML format for
> example '&' to & or '+' sign to ? ?[/color]

'&' needs to be escaped as & but the '+' sign does not need to be
escaped in XML.

How you do it depends on the .NET APIs you use, if you use an
XmlTextWriter to create XML then the WriteString method for instance
does the escaping for you.

If you use the DOM then CreateTextNode simply takes your string and if
the DOM is serialized (e.g. InnerXml, OuterXml, Save) the escaping is
done automatically.



--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Fraser Michael's Avatar
Guest - n/a Posts
#3: Re: Special Characters


It does in the XPATH I am getting the error on the following line:

XMLErrorCollection =
this.m_XMLDoc.SelectSingleNode("./PortfolioCollection/" +
this.m_PortfolioName + "/ErrorCollection");

Where m_PortfolioName = 'test + 1 day'


*** Sent via Developersdex http://www.developersdex.com ***
Martin Honnen's Avatar
Guest - n/a Posts
#4: Re: Special Characters



Fraser Michael wrote:
[color=blue]
> It does in the XPATH I am getting the error on the following line:
>
> XMLErrorCollection =
> this.m_XMLDoc.SelectSingleNode("./PortfolioCollection/" +
> this.m_PortfolioName + "/ErrorCollection");
>
> Where m_PortfolioName = 'test + 1 day'[/color]

Well XPath does not have an XML syntax at all.

With the above you would get the XPath expression
./PortfolioCollection/test + 1 day/ErrorCollection
and that is not syntactically correct as an XPath expression so that is
why you get an error.
Escaping does not help to get the correct syntax.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
 
Not the answer you were looking for? Post your question . . .
196,828 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 196,828 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors