Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Build an XML document.

Posted on 2004-09-04
4
Medium Priority
?
193 Views
Last Modified: 2013-11-19
Hello!

I need some help.

I have an application that builds a lot of xml documents.

I use the

TXMLDocument component but my problem is that this is to slow. (takes a lot of time when building hundred of thosand xml documents.)

Can  someone give me an example of how to build a xml document fast...
0
Comment
Question by:hulken
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11982297
You can try some other XML parser, for example SAX, but I am not sure if for "hundred of thosand" elements it will help you, so that you will notice any difference.

SAX download page:
http://saxforpascal.sourceforge.net/index.html?downloads.html

Here you can see the advantages of SAX:
http://saxforpascal.sourceforge.net/saxdom.html

One of them is supposed to be the speed...
0
 
LVL 2

Expert Comment

by:wqclatre
ID: 11983537
It's not "hundred of thosand" elements in the same document. it's a lot of documents.


I realy don't need to parse the document. I just want to build the document.

(adding node by node).

I have a TObject with a lot of properties that I put in the XML document.
0
 
LVL 7

Expert Comment

by:DavidBirch2dotCom
ID: 11985100
Use the VirtualTreeview component from www.delphi-gems.com IT will cope with many million nodes no problems :)

It has been used for a similar purpose
http://www.soft-gems.net/VirtualTreeview/VTGallery.php

second item down and the item right down at the bottom :)

http://www.xmlblueprint.com/
uses virtual treeview

hope this helps

David
0
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 250 total points
ID: 11988867
Easiest way is by just writing them as textfiles... :-)

var
  AFile:TextFile;
  Buffer:Array[1..16*1024] of char; // Speeds up the files.
begin
  AssignFile(AFile,'Document1.xml');
  Rewrite(AFile);
  SetTextBuf(AFile, Buffer);
  WriteLn(AFile, '<?xml version="1.0" encoding="utf-8"?>');
  WriteLn(AFile, '<?xml-stylesheet type="text/xsl" href="CV.xslt"?>');// If you have a stylesheet...
  WriteLn(AFile, '<CurriculumVitae xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CV.xsd">'); // If you have a schema...
  WriteLn(AFile, '<Personal>');
  WriteLn(AFile, '<Name>Workshop Alex</Name>');
  WriteLn(AFile, '<Personal>');
  // And write whatever else you need to write...
  WriteLn(AFile, '</CurriculumVitae>'); // Final closing tag.
  CloseFile(AFile);
end;
(Beware of the special characters in XML: <> and &

Yeah, I know. It doesn't look that nice but if you're familiar with the XML syntax, this is the fastest way to CREATE new files. If you want to modify, better use one of the existing parsers. Parsers are slower in general, though...

People tend to forget that XML is just basically a textfile format. If you know what you're doing, writing them as textfiles is the fastest method to create a lot of them...
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question