$xml_rec1 = $XMLcon->Data["XML_REC1"][0];
(modify my calling code below to all upercase like XML_REC1 above)
Hope this helps,
Chad.
> -----Original Message-----
> From: Chad Marcusson
> Sent: Monday, November 08, 2004 5:28 PM
> To: [EMAIL PROTECTED]
> Subject: RE: PSC send array via php
>
>
>
> I use this class that I made (Based off some code I found a
> while ago.)
> Read after for how to call...
>
> <!--**********************************************************
> *********************-->
> <?php
> class XMLcon {
> var $Data, $Parser, $Data_Count;
> function StartHandler(&$Parser, &$Elem, &$Attr) {
> global $Data, $CData, $XmlEntities, $Data_Count;
> $CData = array();
> foreach ($Attr as $Key => $Value) {
> if (!isset($Data_Count["$Elem:$Key"]))
> $Data_Count["$Elem:$Key"] = 0;
> $this->Data["$Elem:$Key"][$Data_Count["$Elem:$Key"]]
> = strtr(trim($Value), $XmlEntities);
> $Data_Count["$Elem:$Key"]++;
> }
> }
> function CharacterHandler(&$Parser, &$Line) {
> global $CData;
> $CData[] = $Line;
> }
> function EndHandler(&$Parser, &$Elem) {
> global $Data, $CData, $DataProbs, $Sym, $XmlEntities,
> $Status, $Data_Count;
> if (!isset($Data_Count[$Elem])) $Data_Count[$Elem] = 0;
> $this->Data[$Elem][$Data_Count[$Elem]] = strtr( trim(
> implode('', $CData) ), $XmlEntities);
> $Data_Count[$Elem]++;
> }
> function go($URI) {
> global $XmlEntities, $Data_Count;
> $ParserProbs = array();
> $Data_Count = array();
> $XmlEntities = array('&' => '&', '<' => '<',
> '>' => '>', ''' => '\'', '"' => '"',);
> $Contents = @file_get_contents("$URI");
> if (!$Contents) {
> $ParserProbs[] = "Error Message.";
> continue;
> }
> $Contents = preg_replace('/&(?!\w{2,6};)/', '&', $Contents);
> $Contents = preg_replace('/[^\x20-\x7E\x09\x0A\x0D]/',
> "\n", $Contents);
> $this->Data = ""> > $Parser = xml_parser_create('ISO-8859-1');
> xml_set_element_handler($Parser,
> array(&$this,'StartHandler'), array(&$this,'EndHandler'));
> xml_set_character_data_handler($Parser,
> array(&$this,'CharacterHandler'));
> if ( !xml_parse($Parser, $Contents, TRUE) ) {
> $ParserProbs[] = "Had problem parsing data for
> Symbol\n" . xml_error_string(xml_get_error_code($Parser));
> }
> }
> } //end class
> ?>
> <!--**********************************************************
> *********************-->
>
> Here is how to call it
> <?php
> $URL = "" href="http://www.urltoxml.com">http://www.urltoxml.com";
> require('XMLcon.php');
> $XMLcon = new XMLcon;
> $XMLcon->go($URL);
> $xml_rec1 = $XMLcon->Data["xml_rec1"][0];
> $some_other_xml = $XMLcon->Data["some_other_xml"][0];
> $some_other_xml_child = $XMLcon->Data["some_other_xml"][1];
> ?>
>
> Chad.
>
> > -----Original Message-----
> > From: Raymond [mailto:[EMAIL PROTECTED]
> > Sent: Monday, November 08, 2004 5:17 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: PSC send array via php
> >
> >
> >
> > i'm not a PHP guy so searching thru google and PSC, it
> looks like PHP
> > doesn't have built in XML parsing.. but i found this..
> >
> > http://www.hansanderson.com/php/xml/
> >
> > see you you could make any sense of it...
> >
> >
> > On Mon, 8 Nov 2004 09:12:16 -0000, Sir Daz
> > <[EMAIL PROTECTED]> wrote:
> > >
> > > XML could be the way. Does PHP have built in XML parsing?
> > How would I use
> > > it? Ive never actually used xml with php before.
> > >
> > >
> > >
> > > Thanks,
> > > Darren
> > >
To unsubscribe, send an email to:
[EMAIL PROTECTED]
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/PlanetSourceCode/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
