Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

createProcessingInstruction

2 views
Skip to first unread message

Ron Hinds

unread,
Dec 8, 2009, 1:03:58 PM12/8/09
to
Using this VB code:

Set oProcInstr = oDocOut.createProcessingInstruction("xml",
"version=""1.0""")
oDocOut.insertBefore oProcInstr, oDocOut.childNodes.Item(0)

I can achieve this result in my XML document

<?xml version="1.0" ?>

But, how would I achieve this result?

<?xml version="1.0" encoding="UTF-8"?>

Thanks in advance!


Ron Hinds

unread,
Dec 8, 2009, 5:56:17 PM12/8/09
to
Nevermind, I figured it out. In case anyone else is interested:

Set oAttr = oDocOut.createAttribute("encoding")
oAttr.value = "UTF-8"
oProcInstr.Attributes.setNamedItem oAttr


"Ron Hinds" <nos...@dontspamme.com> wrote in message
news:Oe2dRDDe...@TK2MSFTNGP05.phx.gbl...

Martin Honnen

unread,
Dec 9, 2009, 8:33:44 AM12/9/09
to

Simply use

Set oProcInstr = oDocOut.createProcessingInstruction("xml",

"version=""1.0"" encoding=""UTF-8""")
--

Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/

Ron Hinds

unread,
Dec 10, 2009, 4:17:37 PM12/10/09
to
"Martin Honnen" <maho...@yahoo.de> wrote in message
news:ucuf9QNe...@TK2MSFTNGP04.phx.gbl...

That doesn't seem to work. Although I get no error, the resulting XML
document has no processing instruction at all in it!


Martin Honnen

unread,
Dec 11, 2009, 6:01:11 AM12/11/09
to
Ron Hinds wrote:
> "Martin Honnen" <maho...@yahoo.de> wrote in message
> news:ucuf9QNe...@TK2MSFTNGP04.phx.gbl...
>> Ron Hinds wrote:
>>> Using this VB code:
>>>
>>> Set oProcInstr = oDocOut.createProcessingInstruction("xml",
>>> "version=""1.0""")
>>> oDocOut.insertBefore oProcInstr, oDocOut.childNodes.Item(0)
>>>
>>> I can achieve this result in my XML document
>>>
>>> <?xml version="1.0" ?>
>>>
>>> But, how would I achieve this result?
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>> Simply use
>>
>> Set oProcInstr = oDocOut.createProcessingInstruction("xml",
>> "version=""1.0"" encoding=""UTF-8""")

> That doesn't seem to work. Although I get no error, the resulting XML

> document has no processing instruction at all in it!

Of course you still need to insert that node but that line of code does
not change from what you already posted above.

0 new messages