· May 3, 2018

How to create %XML.Document root with multiple attributes

I need to create a document with a root like this:

<?xml version="1.0" encoding="UTF-8"?>
<RCMR_IN200002FI01 xmlns="urn:hl7-org:v3" ITSVersion="XML_1.0">


However, the CreateDocument in %XML.Document only allows namespace as an additional argument.

I did override this method, but trying to do something like

Do document.SetAttribute("ITSVersion",,"XML_1.0") only results an empty document with the <?xml> declation only.


Discussion (1)1
Log in or sign up to continue

I'll answer myself.

A side note: The method InsertNamespace does not seem to do anything useful with either classes (Document or Node). If anyone knows what it is supposed to do, please let me know.

However upon creation of the document you usually do

Set node=document.GetDocumentNode()

Then you are pointing to the root element and can add attributes at your will.