VerySimpleXML – a lightweight Delphi XML reader and writer

Thursday, November 10th, 2011 | Dennis D. Spreen | Delphi 2009, Delphi 2010, Delphi Programming, Delphi XE, Delphi XE2

There are lot of possibilities if you’re in need to parse or write XML files:

Now here comes another one: VerySimpleXML – a lightweight, one-unit XML reader/writer in under 500 600 lines of code. Use it for small well-formed XML files (like configuration files, etc.).

Download verysimplexml-v1.1.zip (7kb)
Download verysimplexml-v1.0.zip (7kb)

What’s new:
v1.1 – 2012/05/01
changed class name to reflect unit naming (class is now called
TXmlVerySimple instead TVerySimpleXml)
– it uses TStreamReader to read line by line instead of reading the
whole file at once (this allows parsing of big xml files with little
additional memory)
– automatically escapes/unescapes not allowed chars (>, <, “, &), thus
removes the most-hated “- escaping introduced in v1.0

Some usage examples:

VerySimpleXML supports just a subset of the XML specification

  • load and save from stream or file
  • nodes, childs and attributes
  • UTF-8 and ANSI encoding
  • compact output by setting Xml.Ident := ”;
  • method chaining
  • “>” and “>” inside text and attribute values when wrapped in quotation marks (XML-spec requires you to transform them into &lt; etc.)now automatically escaped with v1.1

It does NOT support:

  • CDATA, comments, etc…

Example XML-file:

Warning! This is not a standard well-formed XML file (not all attributes are wrapped with quotation marks, < and > are used within attributes and text), it is an example of the (very simple) fault tolerance of VerySimpleXML. Version 1.1 automatically escapes all non allowed chars.

Tags: ,

113 Comments to VerySimpleXML – a lightweight Delphi XML reader and writer

Jameel Halabi
November 10, 2011

Nice little unit!

I made an adaptation to let it work in FreePascal :)

It’s working right now with FreePascal 2.6.0rc1 which introduced generics syntax compatibility with Delphi, still I need to adapt unicode strings to work with FreePascal style unicode strings, but for now it’s working nicely :)

http://www.mediafire.com/?7erb3crlbk2n5op

Carlos Tré
November 10, 2011

Very nice indeed, thank you very much! :-)

Broto Suseno
November 11, 2011

Is the example a valid XML? IE won’t display, FF shows many errors. After fixing question mark in xml tag and some quotes attributes errors, the feature of storing (node) text wrapped in quotation marks is still complained by FF. Am I missing something? Thanks

Dennis
November 11, 2011

@Broto:
the question mark in the xml tag was just a typo in the example (fixed).

XML-Spec for “well-formed” files requires the attributes wrapped in quotation marks.
VerySimpleXML parses well even without them (if they consist of a single word).

The other non-XML-standard behavior of VerySimpleXML is the usage of the < and > tags inside an attribute or text:
XML spec requires you to write &lt; and &gt; but VerySimpleXML parses well if wrapped in quotation marks.

The XML example just shows these additional VerySimpleXML features. If you feed it with standard well-formed XML files, they will be parsed as well, of course ;-)

danial
November 11, 2011

I has the same issues but was able to fix via validation, i have started using a new xml editor I found recently, http://www.liquid-technologies.com/xml-editor.aspx, anyone know where I can get this for free?

Pol
November 14, 2011

Nice API. Not sure if supporting invalid XML is good idea but at some point it may be useful so thanks for this *subset*-XML and *very subset*-SGML parser ;)

Menjanahary R. R.
November 18, 2011

So nice ! I’ll give it a try. I’ve used Delphi native XML, OmniXML, NativeXML to handle gpx file. Lightweight is appealing.

William Meyer
January 20, 2012

I wonder whether your code can provide me a means of achieving XML of the form:

I have battled with TXMLDocument, with no success. All the examples I have seen will get me something of this form:

But that is unacceptable.

Thanks for your assistance!

William Meyer
January 20, 2012

I wonder whether your code can provide me a means of achieving XML of the form:

I have battled with TXMLDocument, with no success. All the examples I have seen will get me something of this form:

…”

But that is unacceptable.

Thanks for your assistance!

William Meyer
January 20, 2012

My apologies. Apparently I cannot insert XML text in the comment.

Dennis
January 21, 2012

try using [] instead of &glt;

Philip Hutchionson
January 24, 2012

Hi,
I cannot get this code to compile into delphi 7 – do you have a version that will work in 7?

Dennis
January 27, 2012

@Philip:
It uses generics, but it should not be that difficult to rewrite those parts without generics (you need to manually free the list objects).

[…] VerySimpleXML – очень и очень простой парсер. С ним, собственно, я и начал работать сначала из-за его простоты. […]

Eric
March 23, 2012

Hi, Very nice and elegant code.

I wonder if you can add an alternative to FindNodes that takes an Anonymous method as parameter, so that you can loop the nodes without having to create and free a temporary TXmlNodeList.

Something like:
TXmlNodeCallBack = reference to procedure(node : TXmlNode);

procedure TXmlNode.ScanNodes(Name: String; CallBack : TXmlNodeCallBack);
var
Node: TXmlNode;
begin
Name := lowercase(Name);
for Node in ChildNodes do
if (lowercase(Node.NodeName) = Name) then
CallBack(Node);
end;

Philippe Wate
April 3, 2012

Thanks for this great code.
It seems you have a small bug when the file has

and you want to write it back
check it out – I can submit you with example if need be
regards
PW

Philippe Watel
April 19, 2012

Given that it is private
FAttributes: TXmlAttributeList;

I would be nice to have methods to able to enumerate attributes captions and values for a node
You can set and get only as long as you know their names
which you might not know ……
Thank you
best

Dennis
April 20, 2012

You should know all possible attributes of a node – I can’t imagine an example where you’d need a “dynamic unknown” attribute collection?

Philippe Watel
April 26, 2012

Something like that would be acceptable??

property AttibuteCount:integer read GetAttibuteCount;
function ListAttributeNames(Items: Tstrings): Integer;
function ListAttributeValues(Items: Tstrings): Integer;

function TXmlNode.GetAttibuteCount: integer;
begin
if not assigned(FAttributes) then
Exit(0);
Result := FAttributes.Count;
end;

function TXmlNode.ListAttributeNames(Items: Tstrings): Integer;
var
Attribute: TXmlAttribute;
begin
Items.Clear;
if not assigned(FAttributes) then
Exit(0);
for Attribute in Self.FAttributes do
Items.Add(Attribute.Name);
Result := FAttributes.Count;
end;

function TXmlNode.ListAttributeValues(Items: Tstrings): Integer;
var
Attribute: TXmlAttribute;
begin
Items.Clear;
if not assigned(FAttributes) then
Exit(0);
for Attribute in Self.FAttributes do
Items.Add(Attribute.Value);
Result := FAttributes.Count;
end;

Philippe Watel
April 26, 2012

Sorry it should on on a nodelist not a node

Philippe Watel
May 9, 2012

How do you please delete a node

I find it and then I free it but then it cannot save to file
aNode := x.NodeExist(‘flavors’);
if (aNode nil) then
aNode := aNode.Find(‘ROW’, ‘caption’, ‘World’);
if (aNode nil) then
aNode.Free;

then xml.savetofile crashes
any ideas thanks

Dennis
May 10, 2012


...
if (aNode <> nil) then
begin
// remove node from parent childnodes
if (assigned(aNode.Parent)) then
aNode.Parent.Childnodes.Remove(aNode)
end;

If you remove a node, all you have to do is to remove it from the parent childnodes and the node will be freed by the removal procedure.
As only the root node has no parent, you may even omit the “assigned check”, as a “find” call won’t return the root node itself:


...
if (aNode <> nil) then
// remove node from parent childnodes, the node itself will be freed then
aNode.Parent.Childnodes.Remove(aNode);

x2nie
June 6, 2012

Hi Dennis, how to use / test this unit within Delphi 7?

Thanks!

Dennis
June 6, 2012

@x2nie:
As it uses generics, you have to rewrite those generic calls:

e.g.:
replace
TObjectList(TXmlNode) with TList and remove the nodes in the TXmlNode.destroy method “by hand”.

JonR
June 17, 2012

@Dennis:
Delphi 7 has a TObjectList in the Contnrs unit, which has an OwnsObjects property and will free objects when they are removed from the list. You just can’t have a Generics version, so items have to be cast back to TXmlNode.

Pierre
June 18, 2012

Hello Dennis,

I just tried your unit today. I am very new to xml. I don’t know if I messed something up while adapting it to delphi XE, but if I change the value in the BtnGetClick procedure, I get an AV.

for instance :

ShowMessage(Xml.Root.Find(‘book’, ‘id’, ‘bkYYY’).Find(‘description’).Text);

Shouldn’t it not return a value at all or a nil, instead of an AV?
Regards

Dennis
June 18, 2012

@Pierre:
If you’re using fluent interface/method chaining you should be aware of NIL return types (resulting in exceptions), e.g.

ShowMessage(Xml.Root.Find(‘book’, ‘id’, ‘bkYYY’).Find(‘description’).Text);

is the short form of


Node := Xml.Root.Find('book','id','bkYYY');
Child := Node.Find('description');
showmessage(Child.Text);

thus, if Node is NIL (because there is no book with id=bkYYY) then you’ll get an AV right after the Node.Find method call.
Use method chaining with caution and only if you know how your data is structured.
To be sure you should use it like this:


Node := Xml.Root.Find('book','id','bkYYY');
if assigned(Node) then
begin
Child := Node.Find('description');
if assigned(Child) then
showmessage(Child.Text);
end;

Pierre
June 18, 2012

@Dennis:
Ok, I get it. You have done a very good job making verysimplexml. Very easy to use, once you get your head around xml.

Thanks a lot.

[…] XML fetching using XML.VerySimple library […]

[…] saya menemukan sebuah komponen XML parser/XML konstruktor yang cukup stabil untuk dipakai: XML.VerySimple. Komponen ini awalnya dinamakan VerySimpleXML, tapi entah kenapa pembuatnya menamai dengan nama baru […]

ta
September 18, 2012

[Help required]I want to add new “childnode” in the XML file if this childnode is not exist in the file. Is there any function to search the “value” of a childnode in this VerySimpleXML library?

Plz. help me. Thanks

johndoo
September 26, 2012

Hello,

I’ve tried to compile the unit under last version of Lazarus but there are many errors (each time I find a solution with one error, another fires …).

Anyone successfully modified this unit in order to use it with lazarus ?

Thanks

Thomas B.
November 3, 2012

Hello!

I have a stupid question: how can I walk from one node to the next until the end of file is reached?

Thanks

Dennis
November 5, 2012

take a look at the included example:

// Add new keyword attribute (lang=en) to every book
AllNodes := Xml.Root.FindNodes('book');
for BookNode in AllNodes do
begin
Nodes := BookNode.Find('keywords').FindNodes('keyword');
for Node in Nodes do
if not Node.HasAttribute('lang') then
Node.Attribute['lang'] := 'en';
Nodes.Free;
end;
AllNodes.Free;

or you’d just use the Node.ChildNodes list:


MyNode := Xml.Root.FindNode('parentnode');
for NextNode in MyNode.ChildNodes do
begin end;

if you don’t know the parentnode, then fetch it by
calling MyNode.Parent

(see included example)

Alain M.
December 10, 2012

Hello,
When i use Node.Parent.ChildNodes.Remove(Node);
in fact remove an object from Tlist
I’ve always an access violation.
I think something wrong in list but where ?
is it ok for you?
An idea ? thanks

Janvh
January 17, 2013

Hi Dennis,
Thanks for the great work. Lightweight and very flexible. It suits my needs just fine.

Two question however:
1. do you plan to add support for comments?
2. I added a property Attributes: TXmlAttributeList read FAttributes;
to get the attribute count. Do you see any problems in that?

Thanks again!

Dennis
January 21, 2013

@Janvh:
1. I don’t think so. Including comments would require a lot of more code (you could place a comment EVERYWHERE in the document).
2. Sure, that’s quite ok. I’ve added it already in the next code release cycle

Erik
February 3, 2013

It would be cool if comments in XML files were ignored. I have an XML file with a comment line before the RootNode. This comment line becomes the RootNode as the line is treated like a Tag.

Peter
February 23, 2013

Hello all!

There is a small Delphi-TXMLDocument incompatibility in v1.1:

Attribute must read Attributes.

Peter
February 23, 2013

Hi!
I have added some routines to make VerySimpleXML interface more compatible to TXMLDocument.

type
TXmlNodeList = class(TObjectList)
function Get(i: Integer): TXmlNode;
function FindNode(const ANodeName: String): TXMLNode;
end;

function TXmlNodeList.Get(i: Integer): TXmlNode;
begin
Result := Items[i];
end;

function TXmlNodeList.FindNode(const ANodeName: String): TXMLNode;
var
i: Integer;
begin
Result := nil;
for i := 0 to Count-1 do
begin
if (Items[i].NodeName = ANodeName) then
begin
Result := Items[i];
Break;
end;
end;
end;

function TXmlVerySimple.AddChild(const Name: String): TXmlNode;
begin
Result := Root.AddChild(Name);
end;

_Robert
March 27, 2013

Too bad this doesn’t compile in Delphi 7. oh well, DIXml to the rescue.

Dennis
March 27, 2013

No it does not compile below Delphi 2009 because of its generics usage. The Delphi language needs these “evolutions” (generics, etc.) to compete with actual languages and it makes programming with Delphi a lot more structured. I don’t understand those people who are resistent to these technical achievements.

_Robert
March 27, 2013

Generics are fine for novice programmers who have difficulty type-casting. There is no “evolution” to compete with. I have never had a client request a project that delphi 7 couldn’t easily accomplish. I’m an old school ASM programmer, so I’m not impressed with how much prettier things get. I can replicate any project you can make in in D7, it will have less overhead, and an overall smaller size. I enjoy using what I know works.

Dennis
March 27, 2013

The executable is smaller but the source code is way bigger, thus more error prone and less managable (in my opinion). I’m in 2013 and I don’t care about a 30MB exe file instead of 10 MB.
I am an old school asm programmer as well, but I’ve moved forward since these days and enjoyed every new language feature in D2009+ (generics, records, rtti, etc.) – our team produced a way better source code since that…

Well, different persons different opinions ;-)

_Robert
March 27, 2013

True.
As much is I dislike .Net, I have been guilty of writing a few programs in Delphi 2010. Mostly charting applications. It’s refreshing to see someone enthusiastic about newer technologies. My clients usually like keeping things as cross platform as possible.

Been great talking with you Dennis. Good luck.

raynald
July 6, 2013

hello
i have a xml file like that

plcEvtControl
Autor gravage 1 sur H0

plcEvtControl

plcEvtControl
Autor lecture gravage 1 sur H0

plcEvtControl
Autor recul lecture 1 sur H0

plcEvtControl
Autor gravage 2 sur H0

plcEvtControl

plcEvtControl
Autor lecture gravage 2 sur H0

plcEvtControl
Autor recul lecture 2 sur H0

plcEvtControl

plcEvtControl
Autor gravage sur H22

plcEvtControl

plcEvtControl
Autor lecture sur H22

plcEvtControl
Autor recul lecture sur H22

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

plcEvtControl

i want read and write each name and label
thanks to help me

Pete
August 2, 2013

Does anybody know, how to skip/ignore tags?

Pete
August 2, 2013

I meant comment tags.

Dennis
August 2, 2013

Currently not implemented

bruce
August 25, 2013

I especially like that it’s small.
Please do a similar one for JSON.

Pete
August 25, 2013

Has anyone an enhancement skipping comments and DTD tags?

array81
August 28, 2013

Two questions:
– support Firemonkey?
– do you think you will add CDATA support?

thanks

Peter
August 31, 2013

For Firemonkey take this:
http://www.kluug.net/omnixml.php

Philippe Watel
September 5, 2013

hello Thanks for this nice code which will work in any platform under firemonkey because there are no dependencies.
Some addition that would be nice it to be able to give a path for searching for example
‘iosettings//libscan//path’ where // is the PathDelimiter
property PathDelimiter: String read FPathDelimiter write FPathDelimiter;
function PathNode(const fPath: string): TXmlNode;
function PathNodes(const fPath: string): TXmlNodeList;

I did code them, (of course if you want the code I’d gladly pass it on to you) but if you upgrade I would have to do some cut and paste.
Anyway just a suggestion, thank again
regards
PW

array81
November 17, 2013

When I create a node without text I get something like this “”. It’s ok, but I need of this “”.
Is it possible?

Paul Werner
November 29, 2013

Ein netter Fehler: Eine ungerade Anzahl an Quotes führt zu einem Lesefehler über das Ende-Tag hinaus. Man hat dann den xlm-code als Text.

Ansonsten ist das Ding recht gefällig geschrieben. Weiter so!

Gruß Paul

[…] Heute, 01:16 Hallo! Ich teste gerade einen Cross-Platform XML Parser namens "VerySimpleXML". Unter Windows und OS X functioniert alles perfekt. Unter iOS wird die XML-Code falsch eingelesen, […]

Peter
December 20, 2013

Wo ist der Demo-Code zu finden?

Dennis
December 20, 2013

Im Zip, unter Example\

Paul Werner
December 23, 2013

Ein neuer Fehler ist gefunden.
Attribute2 wird nicht gelesen, wenn der Attr-Text vorher ein “/” enthält.

Paul Werner
December 23, 2013

“”

Paul Werner
December 23, 2013

xml text kann man hier nicht posten?

Paul Werner
December 24, 2013

Fehler3: Leeres Attribute value=” ” erzeugt ein Access Violation.

Dennis
December 26, 2013

@Paul: danke für deine Tests, im Moment entsteht gerade eine gefixte Version 2.0, da kommen deine Fehlerreports gerade recht. Danke!

Grawlix
January 26, 2014

Super job. This is incredibly useful for straight shots at small XML files.

I did notice one bit that’s a simplification that’s causing me some problems. Maybe you can comment if that approximation is intention.

Example XML:

Note
Mel Blanc
Joe Alaskey
Dee Bradley Baker
Maurice LeMarche

The element contains line breaks between the names. It appears that your reader assumes that all line breaks are whitespace, and disposes of them.

If I ask for the text for that node, once it’s parsed into a TXMLNode, it returns:

Mel BlancJoe AlaskeyDee Bradley BakerMaurice LeMarche

You’ve generously shown your work, so I’ll dig into it and see what’s happening, but thought you might have a quick thought on it.

Thanks again for your efforts.

Grawlix
January 26, 2014

Oops, code submission problems, let’s try that snippet again:

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>Note</key>
<string>Mel Blanc
Joe Alaskey
Dee Bradley Baker
Maurice LeMarche</string>
</dict>
</plist>

Paul Werner
January 27, 2014

Please try the latest one from here:

http://code.google.com/p/verysimplexml/source/browse/#svn%2Ftrunk%2FSource

Do you still see the same problem?

Paul Werner
January 28, 2014

try finally is missing:

procedure TXmlVerySimple.SaveToFile(const FileName: String);
var
Stream: TFileStream;
begin
Stream := TFileStream.Create(FileName, fmCreate);
try
SaveToStream(Stream);
finally
Stream.Free;
end;
end;

Dennis
January 28, 2014

@paul: thanks, fixed

Paul Werner
January 28, 2014

:-)okay, the same here:
procedure TXmlVerySimple.SetText(const Value: String);

Dennis
January 28, 2014

@paul: thanks again, fixed

Dennis
January 28, 2014

.. I’ll take a look at the other maybe missing exception handlings tomorrow…

Dennis
January 30, 2014

@paul: added exception handling. if you find any other bug, please report it directly to me at dennis@spreendigital.de thanks!

Paul Werner
February 8, 2014

Something that is missing:

1)
function TXmlNodeList.Get(AIndex: Integer): TXmlNode;
begin
Result := TXmlNode(Items[AIndex]);
end;

2)
property IsTextElement: Boolean read GetTextElement;

Dennis
February 8, 2014

Done. Thanks for your input!

Pino
February 11, 2014

Hello, I tried with Delphi VerySimpleXML XE5 for iOS, but it does not work. And ‘possible to optimize it for Delphi XE5 iOS and Android?

Dennis
February 11, 2014

See http://code.google.com/p/verysimplexml/source/browse/#svn%2Ftrunk%2FSource for an actual (beta) version. I am currently testing it, expect a final release in the next days.

Pino
February 11, 2014

Hi, I have implemented your new unit beta version).
How can I process this string?
how can I find the value of
or

procedure myProc;
var
s:string;
begin

//MY XML SAMPLE STRING
S:=
‘ ‘+
‘ ‘+
‘ ‘+
‘ Gambardella, Matthew ‘+
‘ XML Developer's Guide ‘+
‘ An in-depth look at creating XML applications. ‘+
‘ ‘+
‘ ‘+
‘ ‘+
‘ Midnight Rain ‘+
‘ A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world. ‘+
‘ ‘+
‘ no-muerto ‘+
‘ zombies ‘+
‘ flombies ‘+
‘ ‘+
‘ ‘+
‘ ‘+
‘ Corets, Eva ‘+
‘ Maeve Ascendant ‘+
‘ After the "collapse" of a <nanotechnology> society in England, the young survivors lay the foundation for a new society. ‘+
‘ ‘+
‘ fantasy ‘+
‘ technology ‘+
‘ england ‘+
‘ ‘+
‘ ‘+
‘ ‘+
‘ 5″>Corets, Eva ‘+
‘ ‘+
‘ ‘+
‘ ‘+
‘ ‘;

XMLDocMio.Text:=s;

….

end;

MWhittingham
February 11, 2014

BETA 2 on Delphi XE5 Android. Seems to just hang in Loadfromstream (also tried TEXT) when run on device. Works fine when compiled with win32. It did load on the old 1.1 version for what that is worth.

xmldoc := txmlverysimple.Create;
//xmldoc.Encoding := ‘utf-8′;
xmldoc.LoadFromStream(Response);

Node := xmldoc.DocumentElement.ChildNodes.FindNode(‘book’);
ShowMessage(Node.NodeName);
ShowMessage(IntToStr(xmldoc.DocumentElement.ChildNodes.Count));

Dennis
February 11, 2014

iOS and Android testing will be done in about three days, so please be patient or just take a look by yourself. Anyway, thanks for your input! Highly appreciated.

MWhittingham
February 14, 2014

Two thumbs up on the Android support! Thank you for this. TXMLDocument is so slow on Android that I think you have a HOT module here. The performance, size and simplicity it GREAT.

BogdanBBA
February 18, 2014

Is there a way to remove an attribute of a node? Something like/equivalent to:
if aNode.HasAttribute(‘id’) then
aNode.RemoveAttribute(‘id)';

Dennis
February 18, 2014

if aNode.HasAttribute(‘id’) then
aNode.AttributeList.Delete(‘id’)

Dennis
February 18, 2014

which does the same as this:

var
Attribute: TXmlAttribute;
begin
Attribute := aNode.Find(Name);
if Assigned(Attribute) then
aNode.AttributeList.Remove(Attribute);
end;

Paul Werner
February 18, 2014

There is a small error in beta11:

<xml…

? question mark is missing after writing.

Dennis
February 19, 2014

thanks, fixed.

Paul Werner
February 20, 2014

There are several places where AnsiSameText is used. I think it is a bad idea. You won’t read/distinguish valid tags in xml files with e.g.

or

XML is strong case sensitive!

Paul Werner
February 20, 2014

stripped off before:
<peter …
or
<Peter …

Dennis
February 20, 2014

I’m aware that XML is case sensitive, but 99% of the xmls that I’ve found won’t need it – and for convenience I’ve switched over to case insensitive. Well, I’ve thought about that, and added already an option called [doCaseSensitive] (Beta 14, not uploaded yet), but I’m not quite to sure what to use: doCaseSensitive or doCaseInsensitive. I’ll check what ms xml does…

Dennis
February 20, 2014

ok. its strong case sensitive. I’ll add an optional option calles doCaseInsensitive.

Dennis
February 20, 2014

Beta 14 added with (default not set) option doCaseInsenstive – VerySimpleXML is now case sensitive by default

Paul Werner
February 20, 2014

Greater sign is being written wrong:

example text: 123ÄÖÜßEND

VS:
123ÄÖÜß<>END

MSDOM:
123ÄÖÜß<>END

Angus
February 23, 2014

thanks for your great job,i tested it in android/delphi XE5,but i found that ,the memory consumption increase all the time.(from 30M->50M in 2hours)
code:

Timer1Timer();
try
Xml := TXmlVerySimple.Create;
xml.LoadFromFile(..);

..
finally
xml.DisposeOf ; //freeAndnil(); .free
end

Angus
February 23, 2014

sorry, the Timer1 interval is 1000 (1s)
no other object or code in the project.

Dennis
February 23, 2014

@angus: thanks for your report. I’ll take a look. How about the memory consumption on win32 with your xml file?

Angus
February 23, 2014

Dear Dennis, the xml file is the test file with 2notes under 1KB . if the app run in win32,only 12MB memory consumption,and no increase after 2mins,i think the Win32 is ok.and i try to change all the code: “.free” to “.DisposeOf” in your Xml.VerySimple.pas ref: http://docwiki.embarcadero.com/RADStudio/XE4/en/Automatic_Reference_Counting_in_Delphi_Mobile_Compilers

,but no luck.

thanks for your attention.

bob
March 5, 2014

Gambardella, Matthew

Ralls, Kim
Midnight Rain
A former architect battles corporate zombies

no-muerto
no-muerto
no-muerto
test
zombies

Corets, Eva
Maeve Ascendant
The collapse of a society

keywords count error?

bob
March 5, 2014

?

Dennis
March 5, 2014

@bob: please send your xml directly to me dennis@spreendigital.de thanks!

Angus
March 9, 2014

Dear Dennis,
do you have any update about the memory consumption increase in android ?

Dennis
March 10, 2014

@angus: I’ll take a look now (was doing iOS tests lately)

Dennis
March 13, 2014

@angus: please try beta 18, it uses now weak references for the arc nextgen compiler.
you don’t have to use xml.disposeof – just use xmldoc.free as usual.

Angus
March 13, 2014

Dear Dennis,

thanks a lot ,i will check it out.

Angus
March 14, 2014

Dear Dennis,
the Beta 18 works perfect on Android 4.0 now,thanks for your update.

Alessandro Savoiardo
April 2, 2014

Hello Dennis,
if I use this code on Windows:
x := TXmlVerySimple.Create;
x.xml = ‘
città’
The x.ChildNodes.Count is equal 0 but it work on iOS.

I fixed with this code:
in TXmlVerySimple.SetText Line 792
Stream := TStringStream.Create(”, TEncoding.UTF8);

in function TXmlVerySimple.GetText: String; Line 430:
if AnsiSameText(Encoding, ‘utf-8′) then
Stream := TStringStream.Create(”, TEncoding.UTF8)
else
Stream := TStringStream.Create(”, TEncoding.ANSI);

Bye

Alessandro Savoiardo
April 2, 2014

I’m sorry the editor remove xml from code.
The sample is very easy:
NODE DOCUMENT
NODE contain value “città” or accented Characters.
On windows it doesn’t create the nodes with xml property but it work only with Load and Save Stream.

Dennis
April 3, 2014

@Alessandro
Thanks for your bug report and your fix (see beta 21)

Ilia Khubuluri
May 22, 2014

Really great job,
Thanks a lot.
[Delphi developers are still alive]

Ian
June 18, 2014

Dennis, I’m trying to get it to compile in Lazarus (=> Linux).

The only obstacle seems to be the dependency on TStreamReader and TStreamWriter classes, which are painfully slow anyway. Could they be replaced with a targeted (homegrown) replacement?

Targeting Lazarus would enable cross-platform usage of this gem.

Any thoughts?

Grawlix
October 12, 2014

Hello Dennis,

We had some discussion about your excellent work on this component back in February 2014. If I recall correctly, you sent me 1.9 beta, and made reference to 2.0 beta 10, which added escapes to attribute values.

I’ve looked for a more recent version, but do not see it on this site. Have you published it?

Dennis
October 12, 2014

it is finished. most recent version is 2.0 (beta 21) which you’ll find at https://code.google.com/p/verysimplexml/
I’ll update the blog entry the next days and remove the “beta” state – it is considered stable since some months.

[…] Now here comes another one: the updated VerySimpleXML 2.0 – a lightweight, cross-platform, one-unit XML reader/writer for Delphi 2010-XE7 targeting at Win32, Win64, iOS, MacOSX and Android. Use it for well-formed XML files (like configuration files, interprocess communication protocols, etc.). […]

Dennis
October 13, 2014

See above comment for the new 2.0 version.

About Dennis D. Spreen

I'm an avid programmer working on a variety of platforms in a variety of languages with a wide technical interest.

Search

QR Code

Categories