Special Characters

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MAF

    #1

    Special Characters

    Is there a quick way to convert all special characters to XML format for
    example '&' to & or '+' sign to ? ?


  • Martin Honnen

    #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/

    Comment

    • Fraser Michael

      #3
      Re: Special Characters


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

      XMLErrorCollect ion =
      this.m_XMLDoc.S electSingleNode ("./PortfolioCollec tion/" +
      this.m_Portfoli oName + "/ErrorCollection ");

      Where m_PortfolioName = 'test + 1 day'


      *** Sent via Developersdex http://www.developersdex.com ***

      Comment

      • Martin Honnen

        #4
        Re: Special Characters



        Fraser Michael wrote:
        [color=blue]
        > It does in the XPATH I am getting the error on the following line:
        >
        > XMLErrorCollect ion =
        > this.m_XMLDoc.S electSingleNode ("./PortfolioCollec tion/" +
        > this.m_Portfoli oName + "/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
        ./PortfolioCollec tion/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/

        Comment

        Working...