Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Using MSXML from C++

Using MSXML from C++

Scheduled Pinned Locked Moved XML / XSL
c++htmltutorialquestion
9 Posts 3 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    me 0
    wrote on last edited by
    #1

    Not sure if this is the right place to post, but... I am trying to read and write attributes from a DOM. The attributes are of type base64Binary, and I am using IXMLDOMElement::setAttribute(BSTR, VARIANT). How to I package/assign binary data (currently a CDWordArray, but I'm very flexible!!) into/from the variant? Thanks!!!

    M R 2 Replies Last reply
    0
    • M me 0

      Not sure if this is the right place to post, but... I am trying to read and write attributes from a DOM. The attributes are of type base64Binary, and I am using IXMLDOMElement::setAttribute(BSTR, VARIANT). How to I package/assign binary data (currently a CDWordArray, but I'm very flexible!!) into/from the variant? Thanks!!!

      M Offline
      M Offline
      Michael A Barnhart
      wrote on last edited by
      #2

      Using BSTR, Variant should be fine but keep in mind that the memory block you are writting to the document must be compliant with allowed characters. This is espcially true with using the attribute data blocks vs a CData section. Just think of handling the transmission over a http connection. You would have to encode/decode the data. The same concept can apply here. Encode the binary into a string and set it to be the attribute value is one path I have used for smaller sets of information. "I will find a new sig someday."

      M 1 Reply Last reply
      0
      • M Michael A Barnhart

        Using BSTR, Variant should be fine but keep in mind that the memory block you are writting to the document must be compliant with allowed characters. This is espcially true with using the attribute data blocks vs a CData section. Just think of handling the transmission over a http connection. You would have to encode/decode the data. The same concept can apply here. Encode the binary into a string and set it to be the attribute value is one path I have used for smaller sets of information. "I will find a new sig someday."

        M Offline
        M Offline
        me 0
        wrote on last edited by
        #3

        Thanks, no one seems to know much about this..... I have no experiance with http connections/communictions. Is it possible for you to dumb it down a bit? Encoding/decoding to me means stripping out the " ", "<", ">" etc characters, and replacing them when reading. Is this true? Are you aware of any functions available that will do this for me? I've found http://www.codeproject.com/internet/mimesniffer.asp Is this the sort of thing I should be using? My data will typically go to 20 to 30 attributes, each of which will be less than 1 KByte.

        M 1 Reply Last reply
        0
        • M me 0

          Thanks, no one seems to know much about this..... I have no experiance with http connections/communictions. Is it possible for you to dumb it down a bit? Encoding/decoding to me means stripping out the " ", "<", ">" etc characters, and replacing them when reading. Is this true? Are you aware of any functions available that will do this for me? I've found http://www.codeproject.com/internet/mimesniffer.asp Is this the sort of thing I should be using? My data will typically go to 20 to 30 attributes, each of which will be less than 1 KByte.

          M Offline
          M Offline
          Michael A Barnhart
          wrote on last edited by
          #4

          Here is some code I did awhile back. You need to remove nondisplay as well as conflicting characters from the display. CString EnCodeStr(CString ToCode) { CString RetStr,AddStr; int i,max; unsigned short asc; unsigned char c; max = (unsigned int)ToCode.GetLength(); // For binary you need to send the length, The block could have zeros for(i=0;i47 && asc<58) { RetStr+=c; } else if(asc>64 && asc<91) { RetStr+=c; } else if(asc>96 && asc<123) { RetStr+=c; } else if(asc==32) { RetStr+="+"; } else { AddStr.Format("%%%02x",asc); RetStr+=AddStr; } } return RetStr; } CString DeCodeStr(CString ToCode) { CString RetStr,AddStr; int i,max; unsigned short asc; unsigned char c; max = (unsigned int)ToCode.GetLength(); for(i=0;i_"I will find a new sig someday."_

          M 1 Reply Last reply
          0
          • M Michael A Barnhart

            Here is some code I did awhile back. You need to remove nondisplay as well as conflicting characters from the display. CString EnCodeStr(CString ToCode) { CString RetStr,AddStr; int i,max; unsigned short asc; unsigned char c; max = (unsigned int)ToCode.GetLength(); // For binary you need to send the length, The block could have zeros for(i=0;i47 && asc<58) { RetStr+=c; } else if(asc>64 && asc<91) { RetStr+=c; } else if(asc>96 && asc<123) { RetStr+=c; } else if(asc==32) { RetStr+="+"; } else { AddStr.Format("%%%02x",asc); RetStr+=AddStr; } } return RetStr; } CString DeCodeStr(CString ToCode) { CString RetStr,AddStr; int i,max; unsigned short asc; unsigned char c; max = (unsigned int)ToCode.GetLength(); for(i=0;i_"I will find a new sig someday."_

            M Offline
            M Offline
            me 0
            wrote on last edited by
            #5

            That sample's great, thanks. My main concern was what you meant by coding and encoding. If that's good enough then fantastic!!!! thanks again.

            M 1 Reply Last reply
            0
            • M me 0

              That sample's great, thanks. My main concern was what you meant by coding and encoding. If that's good enough then fantastic!!!! thanks again.

              M Offline
              M Offline
              Michael A Barnhart
              wrote on last edited by
              #6

              Glad it helped. Take care. "I will find a new sig someday."

              1 Reply Last reply
              0
              • M me 0

                Not sure if this is the right place to post, but... I am trying to read and write attributes from a DOM. The attributes are of type base64Binary, and I am using IXMLDOMElement::setAttribute(BSTR, VARIANT). How to I package/assign binary data (currently a CDWordArray, but I'm very flexible!!) into/from the variant? Thanks!!!

                R Offline
                R Offline
                Retsof Nawor
                wrote on last edited by
                #7

                Maybe I am missing what Michael is getting at but I don't think he is entirely correct. The base64Binary datatype by definition doesn't require any replacements to be legal in an xml document as when it is encoded it uses the characters 0-9 a-z A-Z '+' '/' ie no replacements required see section 6.8 of http://www.ietf.org/rfc/rfc2045.txt for details (this page is linked to by the Schema spec). Also be aware that most XML DOM do translations required ie you set strings containing '>' '&' etc and they will automatically be converted on output to < and &, however I'm not sure if this is the case for binary types. If possible I would be tempted to use the hexBinary datatype as I find that easier to understand, two characters (0-9 a-f) are used to represent each hex octet ie 0x7f10 would be "7f10" in your XML doc. Hope I haven't confused you...

                M M 2 Replies Last reply
                0
                • R Retsof Nawor

                  Maybe I am missing what Michael is getting at but I don't think he is entirely correct. The base64Binary datatype by definition doesn't require any replacements to be legal in an xml document as when it is encoded it uses the characters 0-9 a-z A-Z '+' '/' ie no replacements required see section 6.8 of http://www.ietf.org/rfc/rfc2045.txt for details (this page is linked to by the Schema spec). Also be aware that most XML DOM do translations required ie you set strings containing '>' '&' etc and they will automatically be converted on output to < and &, however I'm not sure if this is the case for binary types. If possible I would be tempted to use the hexBinary datatype as I find that easier to understand, two characters (0-9 a-f) are used to represent each hex octet ie 0x7f10 would be "7f10" in your XML doc. Hope I haven't confused you...

                  M Offline
                  M Offline
                  me 0
                  wrote on last edited by
                  #8

                  No, that makes a bit more sense to me, and sounds easier to implement and check. Is there an easy way to convert the 0x7f10 to "7f10"? sprintf("%08h", intArray[0]) is OK for an int, but a bit tedious for arrays. Is there a "short cut" here, or am I stuck with a loop? Being able to calculate the length of the final string from the input string seems to me like a major advantage over Michael's code.

                  1 Reply Last reply
                  0
                  • R Retsof Nawor

                    Maybe I am missing what Michael is getting at but I don't think he is entirely correct. The base64Binary datatype by definition doesn't require any replacements to be legal in an xml document as when it is encoded it uses the characters 0-9 a-z A-Z '+' '/' ie no replacements required see section 6.8 of http://www.ietf.org/rfc/rfc2045.txt for details (this page is linked to by the Schema spec). Also be aware that most XML DOM do translations required ie you set strings containing '>' '&' etc and they will automatically be converted on output to < and &, however I'm not sure if this is the case for binary types. If possible I would be tempted to use the hexBinary datatype as I find that easier to understand, two characters (0-9 a-f) are used to represent each hex octet ie 0x7f10 would be "7f10" in your XML doc. Hope I haven't confused you...

                    M Offline
                    M Offline
                    Michael A Barnhart
                    wrote on last edited by
                    #9

                    Thanks for correcting this. I guess I have been working to long. I totally over looked base64Binary was mentioned and just read a binary memory block in a BSTR field. Take Care. "I will find a new sig someday."

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups