CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    28

    Ensuring valid XML element text

    I have read about how to process XML and handle invalid text in element values; what I haven't been able to learn is: how do I ensure the text I _write_ as an XML element value is valid?

    With VC++ 6.0, I'm reading text from an NTEXT database field and writing it with home-grown, text-based XML routines. (I'm not very familiar with DOM, but would be willing to work on it.)

    Is there a way to pass the text thru some character encoding filter to ensure the ampersands (and all other special characters) get converted to & (and their corresponding &xxx; values) ?

    Thanks for reading.

  2. #2
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: Ensuring valid XML element text

    Quote Originally Posted by joleary
    Is there a way to pass the text thru some character encoding filter to ensure the ampersands (and all other special characters) get converted to & (and their corresponding &xxx; values) ?
    Home based routines are nice as long as you are writting extremelly simple and well defined XML's. For the remaining 99% of cases : ) I would recommned using DOM or any other XML library. DOM ensures the XML text is valid and more.
    Har Har

  3. #3
    Join Date
    Mar 2004
    Posts
    28

    Re: Ensuring valid XML element text

    Thanks for the quick reply PadexArt!

    As my naive, home-grown XML writers are _everywhere_ in my system at the moment, can you point me to anything I can use in the meantime, even if I have to drop down (climb up?) into DOM do to a conversion on my string before I write it?

  4. #4
    Join Date
    Aug 2002
    Location
    Cluj-Napoca,Romania
    Posts
    3,496

    Re: Ensuring valid XML element text

    I couldn't tell really. If I had to solve this problem either I would change it with DOM or would make mu own functions using the boost library. They have some pretty usefull string libs.
    Har Har

  5. #5
    Join Date
    Mar 2004
    Posts
    28

    Re: Ensuring valid XML element text

    Thank you again for your consideration, PadexArt.

    I'll look into the boost libraries.

    In the meantime, anyone else have any ideas?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured