Results 1 to 4 of 4

Thread: XML DOM - Processing Instructions

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    XML DOM - Processing Instructions

    I'm having problems when using XML DOM to create XML documents because I want to specify a particular encoding and it doesn't appear to let me:
    Code:
    Dim xmlDoc As MSXML2.DOMDocument40
    Dim pi As MSXML2.IXMLDOMProcessingInstruction
    
    Set xmlDoc = New MSXML2.DOMDocument40
    Set pi = xmlDoc.createProcessingInstruction("xml", "version='1.0' encoding= 'ISO-8859-1'")
            
    xmlDoc.appendChild pi
    But in my generated document, it looks like this:

    <?xml version="1.0" ?>

    i.e. there is no encoding attribute.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: XML DOM - Processing Instructions

    Are you looking at the actual created xml document or are you looking at the xml from within your app via debug? I ask beacuse you won't see the encoding in your app but the output xml file will (at least should) contain it.

  3. #3

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: XML DOM - Processing Instructions

    No, it's actually the other way around. The XML within the app via debug is fine. It is the outputted document that has lost the "encoding" attribute.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: XML DOM - Processing Instructions

    Are you doing a save? E.g. the following which works perfectly for me.

    Code:
    Dim xmlDoc As MSXML2.DOMDocument40
    Dim pi As MSXML2.IXMLDOMProcessingInstruction
    
    Set xmlDoc = New MSXML2.DOMDocument40
    Set pi = xmlDoc.createProcessingInstruction("xml", "version='1.0' encoding= 'ISO-8859-1'")
            
    xmlDoc.appendChild pi
    xmlDoc.save "C:\temp\test.xml"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width