0

I have one application which is passing one (BSTR* ProfileXml) as out parameter. So One I am sending the Profile after allocating it using SysAllocString(Profile)

WCHAR   Profile[] = 
L"<IhvSecurity xmlns=\"http://www.sampleihv.com/nwifi/profile\">"
L"<IHVSecurityParam2>parameter value</IHVSecurityParam2>"
L"</IhvSecurity>";

It' working fine with paramater values for almost all the ascii character (excluding C0 codes like STX ascii code 2 ETX ascii code 3). As soon I send either of STX or ETX that application send error and asking for valid xml buffer, I am using IXMLDOMElement method for loading profile buffer an modifying buffer and saving again buffer. I haven' mention the encoding in Profile string buffer default is utf - 8.

So I am doing some thing wrong here or We cannot use STX / ETX in xml ??? MSMXL parser cannot parse them. Or they some way / API is there to write this into param buffer is node.

Any help will really appreciated

Thanks

mukul sharma
  • 177
  • 2
  • 13
  • Brrr, those kind of control codes used to be used in serial port communications. What are the odds that you got lousy outdated documentation and just don't have to use those control codes anymore to indicate the start and the end of a string? Certainly not necessary in xml. Try it. – Hans Passant Mar 14 '12 at 21:04

1 Answers1

1

You are right, you can't use control characters in XML 1.0. See the specification for the valid range. XML 1.1 adds support for these control characters, but I don't think MSXML supports XML 1.1.

As a workaround you could implement some kind of escaping scheme and then decode it at the other end.

Community
  • 1
  • 1
Greg Inozemtsev
  • 4,516
  • 23
  • 26
  • can you please give some example for escaping this. – mukul sharma Mar 14 '12 at 20:39
  • What I meant was: before including a string as an XML element, escape any invalid characters (those that are not in the ranges given in the XML 1.0 spec). There is no standard way to do this. [One option is \_xhhhh\_, which is apparently what Excel does](http://stackoverflow.com/a/4514421/163956). So STX becomes \_x0002\_. Then whatever software reads the data from XML would have to implement the reverse of this encoding. Finally, any underscore characters in the original string would also have to be escaped, and unescaped by the receiver. – Greg Inozemtsev Mar 15 '12 at 15:19