Web Connection
help with adding 'namespace' to xml document
Gravatar is a globally recognized avatar based on your email address. help with adding 'namespace' to xml document
  Wally W
  All
  Jun 23, 2022 @ 12:16pm

I am using an old version of WebConnect (5.0). I need to create a 'namespace' in my xml document. The programmer who wrote our code retired long ago and I am trying to maintain/update some of the code. Any help on what line of code I would add to this snippet to create a namespace for the following: "aex:AEX_DocUploadNotification xmlns:aex='http://www.aeroxchange.com'"

The code so far is:

  ****START THE DOM
  loXML = CREATEOBJECT('wwXML')
  loDOM = CreateObject('MSXML.DOMDocument')
  *** Load the XML into the DOM
  oXML = CREATEOBJECT("MSXML2.DOMDocument.6.0")
	*********************
	****Add Encoding line
	oPI = oXML.createProcessingInstruction("xml","version='1.0' encoding='UTF-8'")

here is where I thought the namespace code should go, but every attempt so far has failed.

Thanks, Wally

Gravatar is a globally recognized avatar based on your email address. re: help with adding 'namespace' to xml document
  Rick Strahl
  Wally W
  Jun 23, 2022 @ 05:00pm

Namespaces are declared on XML elements that 'define' the namespace and any nodes below it can then use that namespace:

<root xmlns:ns="http://someUniqueUrl.com/">
   <ns:Element1>value</ns:Element1>
   <ns:Element2>value2</ns:Element2>
</root>

The namespace declaration is just an attribute you define on a parent element, and the namespace used is the prefix (ns:Element).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: help with adding 'namespace' to xml document
  Wally W
  Rick Strahl
  Jun 27, 2022 @ 02:19pm

I'm sure that for you this is like teaching a kid one letter of the alphabet, but I cannot seem to format the command to create the namespace command properly. The end result in the xml document should be: <aex:AEX_DocUploadNotification xmlns:aex='http://www.aeroxchange.com'"> but I can't get any command to create this. Thanks for your patience. Wally

Gravatar is a globally recognized avatar based on your email address. re: help with adding 'namespace' to xml document
  Rick Strahl
  Wally W
  Jun 27, 2022 @ 10:58pm

Create an element for the root, then add an attribute with the namespace definition to that element.

+++ Rick ---

© 1996-2022