?
Solved

Build an XML document.

Posted on 2004-09-04
4
Medium Priority
?
192 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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

770 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