× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Mihael -

I ran in to a similar problem parsing data using the EXPAT XML parser
(this was before the xml-sax opcode). Different parser but the same type
of logic applies. Instead of one handler, I have a procedure for each of
the start, end, and character data events.

The trick for me was to use a stack to keep track of the context. So,
when I hit a start tag event, I'd add that tag to the top of the stack,
and clear my "currentValue" field - this will make more sense later. In
retrospect, it would probably have been better to use the XPath as the
stack element, in case there are tags with the same name but different
parent tags. I had a data structure that contained the data I was
interested in. Using your example (quoted below), suppose I only care
about the Nummer for each Kundenstamm, but not the Name. I also want the
whole address. I'd have something like:

Kundenstamm...
DS qualified
Nummer...
like(NummerField)
Anshrift...
DS qualified
Plz...
like(PlzField)
Ort...
like(OrtField)
Strasse...
like(StrasseField)

Now, each time I have an end tag event, I do this:
currentTag = pop(stack);
select currentTag;
when currentTag = '/kundenstamm/nummer';
Kundenstamm.Nummer = currentValue;

when currentTag = '/kundenstamm/nummer/plz';
Kundenstamm.Anshrift.Plz = currentValue;

... and so on. Of course currentValue has to be either a static variable
or a global variable so that it can accumulate data between calls to the
handler.

HTH,
Adam


Mihael Knezevic wrote on 11/04/2007 10:07:54:

xml document:
<?xml version="1.0" encoding="ISO-8859-15" ?>

<kundenstamm>
<nummer>358</nummer>
<name>Dirk Rossmann GmbH</name>
<anschrift>
<plz>32425</plz>
<ort>Minden</ort>
<strasse>Königswall 314</strasse>
</anschrift>
</kundenstamm>

Attention:

The information contained in this message and or attachments is
intended only for the person or entity to which it is addressed and may contain
confidential and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action in reliance upon, this
information by persons or entities other than the intended recipient is
prohibited. If you received this message in error, please contact the sender
and
delete the material from any system and destroy any copies. Thank you for your
time and consideration.

Attention:

Le contenu de ce message et(ou) les fichiers ci-joints s?adressent
exclusivement à la personne ou -entité à laquelle ils sont destinés. Ils
peuvent
contenir de l?information confidentielle, protégée et(ou) classifiée. Il est
strictement interdit à toute personne ou entité autre que le(la) destinataire
prévu(e) de ce message d?examiner, de réviser, de retransmettre ou de diffuser
cette information, de prendre une quelconque action en fonction ou sur la base
de celle-ci, ou d?en faire tout autre usage. Si vous avez reçu ce message par
erreur, veuillez communiquer avec l?expéditeur(trice), supprimer ce message et
les fichiers ci-inclus de tout système, et en détruire toutes copies, qu?elles
soient électroniques ou imprimées. Nous vous remercions de votre entière
collaboration.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.