Hi,

At 2003-05-31 14:52 -0400, [EMAIL PROTECTED] wrote:
>I'm developing a site PHP site.
>
>I would like to define HTML code in XML and be able to get the HTML code using PHP.
>
>I was hoping for a simple example.
>
>I will not be able to update the version of PHP with any "modules" as my hosting 
>company (hostway.com) admins the PHP environment.

I wrote a very compact stand-alone XML interpreter
for the Amazon.com XML webservices interface:

http://www.chipdir.nl/amazon/

The part that interprets the XML code is
only about 30 lines long. Please consider
that I can't guarantee that it's useable
as a general XML-interpreter, because it
was written with the quite neat Amazon
code in mind.

The code may also not be useable for big
source files. Furthermore the code reads
the XML code in such a way that the resulting
array stays as shallow as possible. To this
end certain information is not stored in the
array, and therefore it's not possible
to regenerate the XML code from the array
again.

I have also been busy expanding the script
code into a similar HTML interpreter (which
is much harder of course) but that means
that I don't have a very clear picture in
my head about what the quality of the XML
interpreter currently is. I think I have
found some serious improvements while
working on the HTML version.

One of the problems I encountered whilst trying
to keep the resulting tree shallow was, that
when you interpret something like:

<a>
  <a>_data_
  <b>_data_
  <c>_data_

(I'm leaving out the end-tags.)

You can't put the a,b,c in an associative array,
with a,b,c as index, because every index should
be unique and the sequence might as well be:

<a>
  <a>_data_
  <b>_data_
  <b>...
  <c>

This means that you have to put the elements in
an enumerated array.

But in the case of say:

<author>
  <name>   _data_
  <street> _data_
  <city>   _data_

One really would prefer to put them in an associative
array.

Of course one could check first if all the fields
are unique and decide then, but this might lead
to the fact that XML code like:

<authors>
  <author>_data_
  <author>_data_

<authors>
  <author>_data_

leads to arrays of different depth.

I haven't checked yet if interpreting the DTD
could help to resolve this issue.

Greetings,
Jaap


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to