Unwanted Escape Codes In String...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve Litvack

    Unwanted Escape Codes In String...

    Hello,

    I have built an XMLDocument object instance and I get the following string
    when I examine the InnerXml property:

    <?xml version=\"1.0\" ?><ROOT><UserDa ta UserID=\"2282\" ><Tag1
    QID=\"55111\">< Tag2 AID=\"5511101\" ></Tag2></Tag1><Tag1 QID=\"55112\">< Tag2
    AID=\"5511217\" ></Tag2></Tag1><Tag1 QID=\"5512282\" ><Tag2
    AID=\"551228206 \"></Tag2></Tag1><Tag1 QID=\"55114\">< Tag2
    AID=\"5511406\" ></Tag2></Tag1><Tag1 QID=\"55115\">< Tag2
    AID=\"5511505\" ></Tag2></Tag1></UserData></ROOT>

    Notice that the double quotes are all escaped--that is they appear as

    \"

    versus

    "

    I would like to "transform" or "convert" this string into a string in which
    the escape characters are "converted" . This would generate a string that
    would appear like this:

    <?xml version="1.0"?> <ROOT><UserDa ta UserID="2282">< Tag1 QID="55111"><Ta g2
    AID="5511101"></Tag2></Tag1><Tag1 QID="55112"><Ta g2
    AID="5511217"></Tag2></Tag1><Tag1 QID="5512282">< Tag2
    AID="551228206" ></Tag2></Tag1><Tag1 QID="55114"><Ta g2
    AID="5511406"></Tag2></Tag1><Tag1 QID="55115"><Ta g2
    AID="5511505"></Tag2></Tag1></UserData></ROOT>

    I do not want to use a search/replace algorithm because I cannot be entirely
    sure that there will not be escape sequences other than \" in the string. I
    am actually seeking a solution that would "transform" the \" to " (as I
    require) but also one that would convert \n to ASCII 10 and \r to ASCII 13.
    In other words, I would like to convert the escape-encoded string to a
    standard ASCII string.

    Moreover, why does the XMLDocument's InnerXml return an escape-encoded
    string instead of a "straight" (unencoded) string? Is there a way to get the
    InnerXml to return the "straight" string? I plan to pass the XML string as
    an argument to a Sql stored procedure; therefore, the encoded string does
    not work--I must use the unencoded version. Certainly others have
    encountered this problem--I just could not find a single solution and I
    spend hours searching MSDN and Google! For example, I read some other
    threads that suggest using ActiveXMessageF ormatter, but not one of them
    actually explained how to do it--and pseudocode can only be so useful...

    Thank you in advance for any assistance. I will confirm whether any
    suggestions work.

    Regards,
    Steve






Working...