XML and the "&" URGENT PLEASE


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: XML and the "&" URGENT PLEASE

  1. #1
    Brian Guest

    XML and the "&" URGENT PLEASE


    I have a web form that contains several fields (one file is company name).
    On submit, I take all the fields and build an xml document (see code below)
    strXMLOut = strXMLOut & "<?xml version ='1.0' encoding='ISO-8859-1'?><command>"
    strXMLOut = strXMLOut & "<systemName>Offline</systemName>"
    etc, etc

    If I type in a company of "Jone Glass" everything works GREAT!

    However if I type in "Brown & Jones" as a company name (or anything with
    the "&" symbol)I get an error message in the resulting XML document (see
    below)

    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and
    then click the Refresh button, or try again later.


    --------------------------------------------------------------------------------

    Whitespace is not allowed at this location. Line 1, Position 1676


  2. #2
    gaurav Guest

    Re: XML and the "&" URGENT PLEASE


    Hi Brian
    Use &amp; instead of & in your document,
    gaurav


    "Brian" <bpeski@deloitte.ca> wrote:
    >
    >I have a web form that contains several fields (one file is company name).
    >On submit, I take all the fields and build an xml document (see code below)
    > strXMLOut = strXMLOut & "<?xml version ='1.0' encoding='ISO-8859-1'?><command>"
    > strXMLOut = strXMLOut & "<systemName>Offline</systemName>"
    >etc, etc
    >
    >If I type in a company of "Jone Glass" everything works GREAT!
    >
    >However if I type in "Brown & Jones" as a company name (or anything with
    >the "&" symbol)I get an error message in the resulting XML document (see
    >below)
    >
    >The XML page cannot be displayed
    >Cannot view XML input using XSL style sheet. Please correct the error and
    >then click the Refresh button, or try again later.
    >
    >
    >--------------------------------------------------------------------------------
    >
    >Whitespace is not allowed at this location. Line 1, Position 1676
    >



  3. #3
    Brian Guest

    Re: XML and the "&" URGENT PLEASE


    How do I change what a user types in as "Brown & Jones" in the form textbox
    to "Brown &amp; Jones" that gets passed to the xml document????



    "gaurav" <gauravb2@excite.com> wrote:
    >
    >Hi Brian
    >Use & instead of & in your document,
    >gaurav
    >
    >
    >"Brian" <bpeski@deloitte.ca> wrote:
    >>
    >>I have a web form that contains several fields (one file is company name).
    >>On submit, I take all the fields and build an xml document (see code below)
    >> strXMLOut = strXMLOut & "<?xml version ='1.0' encoding='ISO-8859-1'?><command>"
    >> strXMLOut = strXMLOut & "<systemName>Offline</systemName>"
    >>etc, etc
    >>
    >>If I type in a company of "Jone Glass" everything works GREAT!
    >>
    >>However if I type in "Brown & Jones" as a company name (or anything with
    >>the "&" symbol)I get an error message in the resulting XML document (see
    >>below)
    >>
    >>The XML page cannot be displayed
    >>Cannot view XML input using XSL style sheet. Please correct the error and
    >>then click the Refresh button, or try again later.
    >>
    >>
    >>--------------------------------------------------------------------------------
    >>
    >>Whitespace is not allowed at this location. Line 1, Position 1676
    >>

    >



  4. #4
    Rohit Wason Guest

    Re: XML and the "&" URGENT PLEASE


    >How do I change what a user types in as "Brown & Jones" in the form textbox
    >to "Brown & Jones" that gets passed to the xml document????



    Brian,

    You could replace all & with &amp;. But what will you do with the problem
    with < (&lt > (&gt etc, etc.

    I suggest:

    a) Use DomElement.Text = "Whatever & Whatever", if you are using MSXMLDOM..
    b) or, safest (but slowest if you have long strings): use CDATA:

    <Name><![CDATA[Whatever & Whatever]]></Name>

    this *negates* the special meaning of all such characters..


    HTH
    Cheers
    Rohit



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center