Special Characters in XML ....


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: Special Characters in XML ....

  1. #1
    Harish Kumar Guest

    Special Characters in XML ....


    Hi,

    I've written a component in VB which returns addresses as XML string. From
    my ASP Page, I make a call to this component for which I'm getting back those
    addresses. However the problem comes when there are special characters in
    those addresses - like &.

    I tried using the XML declaration tag like this on top of my ASP page where
    I'm displaying the results -
    <?xml version="1.0" encoding="UTF-16"?>

    Even then I'm getting error because of the presence of special character.
    What's wrong here ? Can some one help me please?

    Regards,
    Harish


  2. #2
    markn Guest

    Re: Special Characters in XML ....


    How are you creating the xml? If you are using a parser to build/parse the
    xml document it will convert them for you.

    Mark

  3. #3
    Harish Kumar Guest

    Re: Special Characters in XML ....


    I changed the DLL in such a way that it returns just plain string now. In
    my ASP page, I've created a data island and load the string output from the
    DLL into that Data Island. But still I encounter error when I get special
    character - &.

    Harish
    "markn" <mnuttall@nospam.com> wrote:
    >
    >How are you creating the xml? If you are using a parser to build/parse

    the
    >xml document it will convert them for you.
    >
    >Mark



  4. #4
    MarkN Guest

    Re: Special Characters in XML ....


    What is the error message you are getting and where are you seeing it at.

  5. #5
    Romulus Guest

    Re: Special Characters in XML ....


    "MarkN" <mnuttall@nospam.com> wrote:
    >
    >What is the error message you are getting and where are you seeing it at.


    Did you try using CDATA?

  6. #6
    Harish Kumar Guest

    Re: Special Characters in XML ....


    As I said earlier, now I changed my component in such a way that it returns
    pretty ordinary string. Example -

    <Recordset>
    <row>
    <BUSINESSNAME>xyz</BUSINESSNAME>
    <ADDRESS>Rosslea</ADDRESS>
    </row>
    <row>
    <BUSINESSNAME>abc & co</BUSINESSNAME>
    <ADDRESS>Londonderry</ADDRESS>
    </row>
    </Recordset>

    In my ASP page, I've created a data island. I'm loading in that data island,
    the above string returned by COM component. Ultimately I've to display these
    addresses in browser for the client.

    Ok, Now where I'm getting the error ? I'm getting error while trying to calculate
    the Record count of my above created data island. I'm trying to find out
    the record count using client side JavaScript like -

    var recCount = document.all.item("CUSTSEARCH").recordset.RecordCount;

    Now, what is the error message that I'm getting? I'm getting a JavaScript
    run time error in my browser (IE 5). The error message doesn't make any sense.


    However, I'm getting this error message only when I encounter a special counter.


    No, I've not tried CDATA.

    Thanks,
    Harish





    "Romulus" <popsromano@hotmail.com> wrote:
    >
    >"MarkN" <mnuttall@nospam.com> wrote:
    >>
    >>What is the error message you are getting and where are you seeing it at.

    >
    >Did you try using CDATA?



  7. #7
    MarkN Guest

    Re: Special Characters in XML ....


    So back to my question - How are you creating the XML in your DLL?

    <row>
    <BUSINESSNAME>abc & co</BUSINESSNAME>
    <ADDRESS>Londonderry</ADDRESS>
    </row>

    Should be

    <row>
    <BUSINESSNAME>abc &amp; co</BUSINESSNAME>
    <ADDRESS>Londonderry</ADDRESS>
    </row>

    if you build it using a parser.



  8. #8
    Larry Triezenberg Guest

    Re: Special Characters in XML ....

    If you're building a string rather than using a parser to build the XML you
    can either designate CDATA sections OR you need to replace out the special
    characters, some of which are:

    "&", "&amp;"
    "<", "&lt;"
    ">", "&gt;"
    """", "&quot;"
    "'", "&apos;"

    A more complete list can be found in the HTML reference guide...

    HTH, Larry

    "Harish Kumar" <Harishm@MailCity.Com> wrote in message
    news:3bf146aa$1@147.208.176.211...

    > No, I've not tried CDATA.





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