Dmitry, you may encapsulate the user provided data inside CDATA sections, and then build the XML elements using them.
CREATE CURSOR CUR_TEMP (NAME C(20), OV M, NV M)
LOCAL UserProvidedName AS String
LOCAL UserProvidedOV AS String
LOCAL UserProvidedNV AS String
LOCAL cAuditDescr AS String
m.UserProvidedName = "Benny & Sons, LLC"
m.UserProvidedOV = "This tests ]]> the end of CDATA section."
m.UserProvidedNV = "Some long description with <, >, & and so forth..."
TEXT TO m.cAuditDescr TEXTMERGE NOSHOW
<?xml version="1.0"?>
<VFPDATA >
<row>
<name><![CDATA[<<STRTRAN(m.UserProvidedName, "]]>", "]]>]]&" + "gt;<![CDATA[")>>]]></name>
<ov><![CDATA[<<STRTRAN(m.UserProvidedOV, "]]>", "]]>]]&" + "gt;<![CDATA[")>>]]></ov>
<nv><![CDATA[<<STRTRAN(m.UserProvidedNV, "]]>", "]]>]]&" + "gt;<![CDATA[")>>]]></nv>
</row>
</VFPDATA>
ENDTEXT
MESSAGEBOX(m.cAuditDescr)
XMLTOCURSOR(m.cAuditDescr, "Cur_Temp", 8192)
BROWSE
>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
----------------------------------
António Tavares Lopes