Re: [PHP] Parsing XML



Per Jessen wrote:
Ashley Sheridan wrote:

On Fri, 2008-11-28 at 10:15 +0100, Per Jessen wrote:
Ashley Sheridan wrote:

Do any of you have a copy of this extension, or failing that, a
suggestion of how I can parse XML files without having to install
anything on the remote server, as I do not have that level off
access to it.
Parsing XML is best done with XSL - if that's out of the question,
you're in for a difficult time.


/Per Jessen, Zürich


XSL will only allow me to convert it into a different document format,
which is not what I want as I need to keep a local copy of information
in a database for searching and sorting purposes. Nathans class allows
me to have the entire document put into an array tree, which is fine
for what I need so far.

That's cool, but XSL is still the more appropriate tool IMO. It does
exactly what you need - it parses and validates the XML document,
allows you to extract the bits you need and in virtually any format you
need - which could be a text document with SQL statements for piping to
mysql.


/Per Jessen, Zürich


I'm with you on this, Per.
You could even use the XSL to construct a bunch of PHP which could be eval'd or
just read in as an include.
Or better yet, if you use the XSL classes, you can register PHP functions and
then call them within your XSL directly. That could potentially handle the
validation you required, and even do the database inserts.

I'm looking into using something like that on a project I'm currently working
on: maybe I can come up with some examples in a couple of days...

--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent
.



Relevant Pages

  • Re: [PHP] Parsing XML
    ... suggestion of how I can parse XML files without having to install ... XSL will only allow me to convert it into a different document format, ...
    (php.general)
  • Re: How to read .xls sheet from C program?
    ... If you want to do it yourself, get the XML and XSL specs from w3.org and parse the files accordingly; I would try implementing it using a state machine. ... You can look for libraries which can parse XML files and write your own XSL stuff. ... Or: You can look for libraries directly handling XSLT or XSL:FO. ...
    (comp.lang.c)
  • Re: How to read .xls sheet from C program?
    ... If you want to do it yourself, get the XML and XSL specs from w3.org and parse the files accordingly; I would try implementing it using a state machine. ... You can look for libraries which can parse XML files and write your own XSL stuff. ... Or: You can look for libraries directly handling XSLT or XSL:FO. ...
    (comp.lang.c)
  • Re: [PHP] Parsing XML
    ... suggestion of how I can parse XML files without having to install ... Parsing XML is best done with XSL - if that's out of the question, ... XSL will only allow me to convert it into a different document format, ... but XSL is still the more appropriate tool IMO. ...
    (php.general)