473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

CreateXMLFile

I am trying to load an XML document in a basic derived language the
supports COM. here is my code

Sub CreateXMLFile ()
Dim XMLDoc as Object
const FILEPATH as string = "C:\xml_log.xml"

sXML = "<testresults>" & sXML & "</testresults>"

Set XMLDoc = CreateObject("Microsoft.XMLDOM")
XMLDoc.async = False
XMLDoc.loadXML(sXML)
XMLDoc.save(FILEPATH)

End sub

This is what appears in variable sXML just before we assign the object
reference (formatted of course)

<testresults>
<test id=TESTID_10>
<teststatus>pass</teststatus>
<test id=TESTID_20>
<teststatus>fail</teststatus>
</testresults>

I have got two problems

1) Nothing appears in 'C:\xml_log.xml'
2) Also, I am unsure on how to add the XML declaration '<?xml
version="1.0"?>'

All help appreciated.

Cheers

Aidy

Mar 28 '06 #1
4 1987


aidy wrote:

This is what appears in variable sXML just before we assign the object
reference (formatted of course)
That is not well-formed:
<testresults>
<test id=TESTID_10> ^^^^^^^^^
attribute values need to be quoted
<teststatus>pass</teststatus>

where is the closing </test> tag?
loadXML returns a boolean value indicating whether the markup was parsed
successfully or not.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 28 '06 #2
Martin,

Thanks for your help. It's working.

Aidy

Mar 29 '06 #3
Sorry. One more question. I can't seem to find a close method for the
DOM object

Set XMLDoc = CreateObject("Microsoft.XMLDOM")
XMLDoc.async = False
If XMLDoc.loadXML(sXML) = 0 then msgbox "XML not parsed"
XMLDoc.save(FILEPATH)

Is there one? How does the XML parser shut-down?

Aidy

Mar 29 '06 #4


aidy wrote:
I can't seem to find a close method for the
DOM object

Set XMLDoc = CreateObject("Microsoft.XMLDOM")
XMLDoc.async = False
If XMLDoc.loadXML(sXML) = 0 then msgbox "XML not parsed" Is there one? How does the XML parser shut-down?


There is no close method. If the parser finds an error that the markup
is not well-formed then parsing is stopped and the error is reported as e.g.
XMLDoc.parseError
with properties
XMLDoc.parseError.reason
see
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/fdc6ff87-3cfb-4aa0-8bb6-d8c1acf9684e.asp>

If the above is VBScript then you would do e.g.
Set XMLDoc = Nothing
once you are done with the object and want to free it.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 29 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: asrs63 | last post by:
Hi, I am a newbee and have a comma seperated flat-file and a DTD. I need to write a C# program which will read the text file and convert it to a XML file as per the the definition in the DTD. I...
2
by: Chris Stiefeling | last post by:
Hi, I am experiencing a strange problem. I am reading and writing xml files via XmlDocument and XmlTextWriter. In the debugger everything works fine but outside the debugger (debug or release)...
1
by: Chris Stiefeling | last post by:
Hi, I am experiencing a strange problem. I am reading and writing xml files via XmlDocument and XmlTextWriter. In the debugger everything works fine but outside the debugger I receive the...
14
by: neerajb | last post by:
Hi, I am having an XML document(input.xml) which is showing the menu heirarchy used in my application.My requirement is to add "submenu" tag to those menuitems who are having the child menuitems...
7
by: Hans | last post by:
Hello, I have a few questions about the My.Settings user configuration. Is it posible to change the filepath of the my.settings userconfig file ? Is it posible to have different files so i...
1
by: =?Utf-8?B?U3RldmVU?= | last post by:
I have a structure that contains both 32x32 and 16x16 icons plus some text. I want to write all this to an XML file so that I can recover the icons later in an application. Can someone tell me how...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.