Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating XML file with VB6

Status
Not open for further replies.

xjazz

Programmer
Jan 11, 2005
21
US
my program needs to write some information into a log file.
now I use XML file as this log.

I was using XML object to create and add entries. but seems it will slow down the perfermance.bigger the file, longer it takes to add an entry.

so I decide to use file functions to do that.
I use "open" function to open the log file and use "print" function to add entry, log file format is still .xml .
however I have one more problem.
some msg contain "&", so when I write string like "blah blah & blah" into this log file.
then the XML file can't be dispalyed.
the error will be:
Whitespace is not allowed at this location. Error processing resource 'testing.XML'. Line...

blah blah & blah
-----------^


what should I do?
thanks in advance
 
Code:
strBlahBlah=replace(strBlahBlah,"&","AND")

before u write to the xml file

If somethings hard to do, its not worth doing - Homer Simpson
 
thanks

but is there other restrictions?
how about "\"? "|"... ?

do I just need to take care of "&"?

thanks
 
i dont know much about xml, but i imagine there are more restrictions (CRLF for example)

If somethings hard to do, its not worth doing - Homer Simpson
 
that's the point
:(

btw: just tried put "CRLF" in.
but nothing happened.
 
hmm just done some googling.

& is the escape character and should be replaced by &amp.

so

Code:
strBlahBlah=replace(strBlahBlah,"&","&amp")

good luck

If somethings hard to do, its not worth doing - Homer Simpson
 
hmmm
thanks

but you missed a ";"
it should be:
strBlahBlah=replace(strBlahBlah,"&","&")


 
I was using XML object to create and add entries. but seems it will slow down the perfermance.bigger the file, longer it takes to add an entry.
I would take this as a sign that XML is probably not the best way to write log files. As you've found out, once a document starts to get "big", things slow down.

I would use plain old text for your logfile, and provide a utility to convert it to XML afterwards.

Chip H.


____________________________________________________________________
Click here to learn Ways to help with Tsunami Relief
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top