AID = \" 5511406 \">< / Tag2>< / Tag1>< Tag1 QID = \" 55115 \">< Tag2 AID = \" 5511406 \">< / Tag2>< / Tag1>< Tag1 QID = \" 55115 \">< Tag2 AID = \" 5511406 \">< / Tag2>< / Tag1>< Tag1 QID = \" 55115 \">< Tag2 Hello,I have built an XMLDocument object instance and I get the following stringwhen I examine the InnerXml property:<?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1QID=\"55111\"><Tag2 AID=\"5511101\"></Tag2></Tag1><Tag1 QID=\"55112\"><Tag2AID=\"5511217\"></Tag2></Tag1><Tag1 QID=\"5512282\"><Tag2AID=\"551228206\"></Tag2></Tag1><Tag1 QID=\"55114\"><Tag2AID=\"5511406\"></Tag2></Tag1><Tag1 QID=\"55115\"><Tag2AID=\"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 whichthe escape characters are "converted". This would generate a string thatwould appear like this:<?xml version="1.0"?><ROOT><UserData UserID="2282"><Tag1 QID="55111"><Tag2AID="5511101"></Tag2></Tag1><Tag1 QID="55112"><Tag2AID="5511217"></Tag2></Tag1><Tag1 QID="5512282"><Tag2AID="551228206"></Tag2></Tag1><Tag1 QID="55114"><Tag2AID="5511406"></Tag2></Tag1><Tag1 QID="55115"><Tag2AID="5511505"></Tag2></Tag1></UserData></ROOT>I do not want to use a search/replace algorithm because I cannot be entirelysure that there will not be escape sequences other than \" in the string. Iam actually seeking a solution that would "transform" the \" to " (as Irequire) 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 astandard ASCII string.Moreover, why does the XMLDocument''s InnerXml return an escape-encodedstring instead of a "straight" (unencoded) string? Is there a way to get theInnerXml to return the "straight" string? I plan to pass the XML string asan argument to a Sql stored procedure; therefore, the encoded string doesnot work--I must use the unencoded version. Certainly others haveencountered this problem--I just could not find a single solution and Ispend hours searching MSDN and Google! For example, I read some otherthreads that suggest using ActiveXMessageFormatter, but not one of themactually explained how to do it--and pseudocode can only be so useful...Thank you in advance for any assistance. I will confirm whether anysuggestions work.Regards,Steve 解决方案 It is the C# escape character, i.e. "\", as well as C and C++.You do not have to replace it with anythng. Just leave it.Just pass it to your stored procedure as is, it will work OK."Steve Litvack" <us************@yahoo.com> wrote in messagenews:RD********************@twister.austin.rr.com. .. 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><UserData UserID=\"2282\"><Tag1 QID=\"55111\"><Tag2 AID=\"5511101\"></Tag2></Tag1><Tag1QID=\"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 inwhich the escape characters are "converted". This would generate a string that would appear like this: <?xml version="1.0"?><ROOT><UserData 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> I do not want to use a search/replace algorithm because I cannot beentirely 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 ASCII13. 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 getthe 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 ActiveXMessageFormatter, 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 It is the C# escape character, i.e. "\", as well as C and C++.You do not have to replace it with anythng. Just leave it.Just pass it to your stored procedure as is, it will work OK."Steve Litvack" <us************@yahoo.com> wrote in messagenews:RD********************@twister.austin.rr.com. .. 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><UserData UserID=\"2282\"><Tag1 QID=\"55111\"><Tag2 AID=\"5511101\"></Tag2></Tag1><Tag1QID=\"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 inwhich the escape characters are "converted". This would generate a string that would appear like this: <?xml version="1.0"?><ROOT><UserData 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> I do not want to use a search/replace algorithm because I cannot beentirely 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 ASCII13. 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 getthe 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 ActiveXMessageFormatter, 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 Can you post your SP code as well as the code that creates SP paramaters?"Steve Litvack" <us************@yahoo.com> wrote in messagenews:Ps********************@twister.austin.rr.com. .. No--it does not work. That is why I posted the message. SQL Server reports: Server: Msg 6603, Level 16, State 1, Procedure sp_xml_preparedocument,Line 27 XML parsing error: A string literal was expected, but no opening quote character was found. If anyone has any ideas on how to generate the "pure" ASCII XML text I requested, please let me know. Thanks, -- Steve "dd" <so*****@somewhere.com> wrote in message news:uS********************@news20.bellglobal.com. .. It is the C# escape character, i.e. "\", as well as C and C++. You do not have to replace it with anythng. Just leave it. Just pass it to your stored procedure as is, it will work OK. "Steve Litvack" <us************@yahoo.com> wrote in message news:RD********************@twister.austin.rr.com. .. 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><UserData 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 stringthat would appear like this: <?xml version="1.0"?><ROOT><UserData 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> 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 " (asI require) but also one that would convert \n to ASCII 10 and \r toASCII 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 toget the InnerXml to return the "straight" string? I plan to pass the XMLstring 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 andI spend hours searching MSDN and Google! For example, I read some other threads that suggest using ActiveXMessageFormatter, but not one ofthem actually explained how to do it--and pseudocode can only be souseful... Thank you in advance for any assistance. I will confirm whether any suggestions work. Regards, Steve 这篇关于字符串中不需要的转义码...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
05-25 08:39