Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XMLTOCURSOR() and bad characters
Message
General information
Forum:
Visual FoxPro
Category:
XML, XSD
Miscellaneous
Thread ID:
01673619
Message ID:
01673793
Views:
51
Thank you for your input.

I have implemented the approach suggested by Antonio Lopes, using the CDATA. And so far I have not seen one error. Works very well.

>I really wouldn't recommend editing XML directly precisely for this reason. Turning data 'back into valid characters' in badly formed XML is not as easy as it sounds because the characters in question are the ones that make the elements and attributes in a document.
>
>The better way is to edit the data as data then convert the data from an object (or a record in a table) to XML and get it properly encoded. There are many more issues here than just those characters - extended characters, UTF-8 encoding, line feeds, tabs etc. etc. It's just not a good idea. It'll be quicker to just dump the data into a proper fields and building a quick and dirty input form than it is to make sure you end up with valid XML in all cases that you're not accounting for.
>
>+++ Rick ---
>
>>Antonio,
>>
>>The XML is based on a content of a memo field (editbox) on one of the forms.
>>What I am thinking to do is, before converting the memo into the string and into the XML, search for any of these "bad" characters and convert them to "good" characters. For example, convert
<
to LT,
>
to GT and
&
to Ampersand.
>>I don't know how often users actually use these characters. I came upon them when testing and using my sample DB where I use all kind of weird characters.
>>Thanks
>>
>>>Dmitry,
>>>
>>>Since you're allowing the user to edit or prepare the XML document, there is not much you can do besides error trapping. Using current parsers like MSXML you cannot turn a not well-formed XML document into a well-formed XML document. You would have to write a parser for the effect.
>>>
>>>Does the user has to prepare the data for your system in XML?
>>>
>>>>Hi,
>>>>
>>>>I am converting a string into a cursor. The string has values entered by the user (so, I have no control). Here is the simple example:
>>>>
>>>>CREATE CURSOR CUR_TEMP (NAME C(20), OV M, NV M)
>>>>XMLTOCURSOR( cAuditDescr, 'CUR_TEMP', 8192 )
>>>>
>>>>
>>>>What happens is the string cAuditDescr could have characters such as a Less-Than (
<
, Ampersand
&
, Greater-Than (
>
). Any of these characters cause a run-time error.
>>>>
>>>>How do you suggest I change the code above to allow the values to be in the cursor ("CUR_TEMP") without a run-time error?
>>>>
>>>>TIA
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform