Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replacing Ampersand in a string for XML
Message
 
 
À
16/10/2018 10:44:41
Information générale
Forum:
Visual FoxPro
Catégorie:
XML, XSD
Divers
Thread ID:
01662605
Message ID:
01662610
Vues:
40
>>Hi,
>>
>>My code converts a string (field of a cursro) to an XML string and to a cursor. And if the string contains an ampersand sign (&), the process fails.
>>
>>This is the segment of the code:
>>
>>cAuditDescr = '<?xml version = "1.0" encoding="Windows-1252" standalone="yes"?><Changes>' +
>>ALLTRIM(C_POAUDIT.AUDIT_DESC) + '</Changes>'
>>XMLTOCURSOR( cAuditDescr, 'CUR_TEMP', 8192 )
>>
>>The error happens on the line XMLTOCURSOR() when the string AUDIT_DESC has an ampersand. I can pre-process the entry and either strip all occurrences of ampersand or replace it? Getting rid is pretty straight forward. But if I want to replace it, what character should be used?
>>
>>TIA
>
>Hi, Dmitry.
>
>STRTRAN(ALLTRIM(C_POAUDIT.AUDIT_DESC), "&", "&" + "amp;") would do.
>
>If AUDIT_DESC is not XML to start with, you should also make sure that other characters that may break the XML ingestion are properly handled.
>
>Something like:
>
>
>STRTRAN(STRTRAN(STRTRAN(ALLTRIM(C_POAUDIT.AUDIT_DESC), "&", "&" + "amp;"), "<", "&" + "lt;"), ">", "&" + "gt;")
>
Hi Antonio,
Thank you very much!
"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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform