Jump to content
Sign in to follow this  
MrMMM

XML Root node / _XMLCreateFile

Recommended Posts

MrMMM

Hello,

I have an autoit script that takes an excel file an creates an XML file out of it. However, I am having a problem creating a very specific Root Node.

The code I have right now:

_XMLCreateFile($sFileName, "root", True, True)

However, the root node needs to look like this:

<my-feed xmlns="[url="http://address.com/schemas/feed/offers/2010-06"]http://address.com/schemas/feed/offers/2010-06"[/url]>
    <generation-date>2001-12-31T12:00:00+04:00</generation-date>

</my-feed>

How can I use the _XMLCreateFile command to generate this root node?

Thank you very much!

Share this post


Link to post
Share on other sites
jdelaney

$oXML=ObjCreate("Microsoft.XMLDOM")
$oRoot = $oXML.createElement("my-feed")
$oRoot.setAttribute("xmlns",'http://address.com/schemas/feed/offers/2010-06')
$oChild = $oXML.createElement("generation-date")
$oChild.text = "2001-12-31T12:00:00+04:00"
$oRoot.appendChild($oChild)
$oXML.appendChild($oRoot)
ConsoleWrite ( $oXML.xml)

output:

<my-feed xmlns="http://address.com/schemas/feed/offers/2010-06"><generation-date>2001-12-31T12:00:00+04:00</generation-date></my-feed>
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
MrMMM

Thank you for your reply, but I guess I am not versed enough in XML to understand how to get it to create the root node in the output file (not on the console).

I cannot find a built in function that would allow to create a root node outside of the _XMLCreateFile function.

Share this post


Link to post
Share on other sites
jdelaney

The xmldom method is .save google it, there is a param for the file to save to.

Or, take the string, use _createfile, and write into it with filewrite.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×