XML Schema (1 Viewer)

Freshman

Registered User.
Local time
Today, 18:16
Joined
May 21, 2010
Messages
437
Hi all,

I need to export a Query to XML to be used in a PhP script.
However the XML output format differ from the example I have.
The example is far more simplistic so I need to get rid of the extra stuff.
I assume that I would need to use a schema to correct this but I've been unable to get the syntax correct.

Current Output
Code:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" generated="2015-06-25T07:02:27">
<_x0031_23>
<password>abc</password>
</_x0031_23>
</dataroot>
Output I need:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<user>
<password>abc</password>
</user>
Schema I tried to use (xsl file type)
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/1999/XSL/Transform" xmlns:od="urn:schemas-microsoft-com:officedata">
<user>
<password>abc</password>
</user>
</xsd:schema>
Can someone help with this please?

Thanks a lot
Pierre
 

namliam

The Mailman - AWF VIP
Local time
Today, 17:16
Joined
Aug 11, 2003
Messages
11,695
I have found that creating XML from VBA is best done by actually writing the file yourself using Open to create the file, Print to write the lines into the file.
 

Freshman

Registered User.
Local time
Today, 18:16
Joined
May 21, 2010
Messages
437
Hi Namliam,
Sorry but I'm missing you on this one. What must I "open" and what must I "print"
Can you be more specific to help me understand.
Thanks again
 

spikepl

Eledittingent Beliped
Local time
Today, 17:16
Joined
Nov 3, 2010
Messages
6,142
open a text file for writing and write the desired lines one by one yourself is what namliam wrote and I concur
 

Freshman

Registered User.
Local time
Today, 18:16
Joined
May 21, 2010
Messages
437
Thanks guys. My mind was still stuck on the Export side. But I now see what he meant - it is a clever 'workaround' to create the XML file inside a text file but as a XML file type.
Will try that as I'm sure it will do the trick
 

Freshman

Registered User.
Local time
Today, 18:16
Joined
May 21, 2010
Messages
437
Just to report back for anyone else reading this post in the future.
The example code below works perfect
Thanks again for the out-the-box idea :)

Private Function CreateAfile()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile("c:\testfile.xml", True)
a.WriteLine ("<user><password>abc</password></user>")
a.Close
End Function
 

namliam

The Mailman - AWF VIP
Local time
Today, 17:16
Joined
Aug 11, 2003
Messages
11,695
Not quite the Open/print idea I gave you but using the FileSystemObject works just as well :)

Course your sample is missing the headers and footers of the xml you required.
 

Users who are viewing this thread

Top Bottom