[PHP] how to modify xml files using php

2001-04-20 Thread Serge Vleugels


hi,

I've got to change a XML document,
so read the file, display it, provide a way to modify it and then write
the modifications.
has anyone done this allready or has any experiance ?

thx

Serge "Zeddicus Zu'l Zorandre" Vleugels

-- freedom is the wizard's only choice --



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] 'XML To Array' Class

2001-04-23 Thread Serge Vleugels

heey,

i'm currently facing the same problem as you.
i was thinking of using either xml_parse_into_struct or using 
a class i found phpxml.class at http://www.phpxml.org
let me know how you did it, i'm very intrested

Serge "Zeddicus Zu'l Zorandre" Vleugels

-- freedom is the wizard's only choice --


On 23 Apr 2001 09:18:25 -0400, [EMAIL PROTECTED] wrote:
> Hello,
> 
> I'm new to using XML with PHP, but I think I've got it figured out for 
> the most part.  I have created a class that reads in an XML file and 
> returns the data it finds to an array, but I'm running into a problem 
> because the array keeps coming back empty.  Would you mind taking a 
> moment to see where I'm going wrong?
> 
> 
> file.xml
> ===
> 
> 
> /article1.html
> Article 1
> 
> 
> 
> /article2.html
> Article 2
> 
> 
> 
> 
> xml.class.php
> ===
> 
> 
>  
> 
>   class eXML
>   {
> 
> 
>   var $Parser;
> 
>   var $theArray;
>   var $theArrayTopElement;
>   var $theArrayElements;
>   var $theArrayPointer;
>   var $theArrayGetElement;
> 
> 
>   function eXML($_PARENT_, $_CHILDREN_)
>   {
> 
>   $this->Parser = xml_parser_create("ISO-8859-1");
>   xml_set_object($this->Parser, &$this);
>   xml_set_element_handler($this-
> >Parser, "Tag_Open", "Tag_Close");
>   xml_set_character_data_handler($this-
> >Parser, "CData");
> 
>   $this->theArray = array();
>   $this->theArrayPointer = 0;
>   $this->theArrayGetElement = NULL;
>   $this->theArrayTopElement = $_PARENT_;
>   $this->theArrayElements = $_CHILDREN_;
> 
>   }
> 
> 
>   function Free()
>   {
> 
>   xml_parser_free($this->Parser);
> 
>   }
> 
> 
>   function Parse_Array($_FILE_)
>   {
> 
>   $_FP_ = fopen($_FILE_, "r") or die("Cannot Open 
> XML Stream");
> 
>   while ($_DATA_ = fread($_FP_, 4096))
>   {
> 
>   if (!xml_parse($this->Parser, $_DATA_, 
> feof($_FP_)))
>   {
> 
>   return(FALSE);
> 
>   }
> 
>   }
> 
>   fclose($_FP_);
>   var_dump($this->theArray);
>   return($this->theArray);
> 
>   }
> 
> 
>   function Tag_Open($_PARSER_, $_TAG_, $_ATTR_)
>   {
> 
>   if ($_TAG_ == $this->theArrayTopElement)
>   {
> 
>   $this->theArray[$this->theArrayPointer] 
> = "SOMETEXT";
> //  NOT SURE IF THIS IS NECESSARY
> 
>   }
> 
>   $_ELEMENTS_ = explode("::", $this-
> >theArrayElements);
>   for ($I = 0; $I < count($_ELEMENTS_); $I++)
>   {
> 
>   if ($_TAG_ == $_ELEMENTS_[$I])
>   {
> 
>   $this->theArrayGetElement = 
> $_ELEMENTS_[$I];
> 
>   }
> 
>   }
> 
> 
>   }
> 
> 
>   function Tag_Close($_PARSER_, $_TAG_)
>   {
> 
>   if ($_TAG_ == $this->theArrayTopElement)
>   {
> 
>   $this->theArrayPointer++;
> 
>   }
> 
>   $this->theArrayGetElement = NULL;
> 
>   }
> 
> 
>   function CData($_PARSER_, $_CDATA_)
>   {
> 
>   if ($this->theArrayGetElement != NULL)
>   {
> 
>   array_push($this->theArray, $_CDATA_);
>   $this->theArray[$this->theArrayPointer]
> [$this->theArrayGetElement] = $_CDATA_;
> 
>   }
> 
>   }
> 
>   }
> 
> 
> ?>
> 
> 
> 
> xml.test.php
> ===
> 
>  
> 
>   $XML = new eXML("ARTICLE", "URL::TITLE");
>   $ARTICLES = $XML->Parse_Array("file.xml");
>   print_r($ARTICLES);
> 
> 
> ?>
> 
> 
> What I expect to happen is this:
> 
> $ARTICLES[0]["URL"] == "/article1.html";
> $ARTICLES[0]["TITLE"] == "Article 1";
> $ARTICLES[1]["URL"] == "/article2.html";
> $ARTICLES[1]["TITLE"] == "Article 2";
> 
> But the array is empty.
> 
> Thankz in advance for your help.
> Robert
> 
> 
> 
> -- 
> 
> [ Swift eNetwork ] Matrix
> http://matrix.swifte.net/
> 
> --
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscrib

RE: [PHP] Databases and HTML forms

2001-05-07 Thread Serge Vleugels

check out phpMyAdmin
i use it everywhere

Serge



-Original Message-
From: Manuel Lemos [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 07, 2001 4:22 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Databases and HTML forms


Hello Michael,

On 20-Apr-01 14:38:48, you wrote:

>I'm needing to have a form that pulls a bunch of database fields into
it and
>then allows you to modify the fields and does the subsequent update in
the
>database.  This seems like something that has to be done all the time.
Is
>there a right way to go about doing this?  Some kind of class library
or
>anything?  Or do I just kind of code it up?  Thanks for any responses.

Right, you may want to check this PHP class that does exactly what you
need:

http://phpclasses.UpperDesign.com/browse.html/package/231

Regards,
Manuel Lemos

Web Programming Components using PHP Classes.
Look at: http://phpclasses.UpperDesign.com/?[EMAIL PROTECTED]
--
E-mail: [EMAIL PROTECTED]
URL: http://www.mlemos.e-na.net/
PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
--


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]