PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Extract metadata from an xml
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Extract metadata from an xml

Réponse
 
LinkBack Outils de la discussion
Vieux 14/02/2008, 11h54   #1
ofuuzo1@yahoo.no
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Extract metadata from an xml

The below xml is generated when I make a remote call like:

?php
$url = "http://......./oai?
verb=ListRecords&metadataPrefix=frida&set=UUI";
$input = @file_get_contents($url) or die('Could not access file:
$url');
echo $input;
?>
How can I extract only
<resumptionToken completeListSize="14" cursor="0">set+UITO+cls
+14+cursor+3+last+110547</resumptionToken>

and put it in a variable?

Thanks in advance.
Ofuuzo

----------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
schemaLocation="http://www.openarchives.org/OAI/2.0/
http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
<responseDate>2008-02-14T12:41:33Z</responseDate>
.....
......
</record>
<resumptionToken completeListSize="14" cursor="0">set+UITO+cls
+14+cursor+3+last+110547</resumptionToken>
</ListRecord>
</OAI-PMH>
  Réponse avec citation
Vieux 14/02/2008, 12h42   #2
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Extract metadata from an xml

On Thu, 14 Feb 2008 12:54:07 +0100, <ofuuzo1@yahoo.no> wrote:

> The below xml is generated when I make a remote call like:
>
> ?php
> $url = "http://......./oai?
> verb=ListRecords&metadataPrefix=frida&set=UUI";
> $input = @file_get_contents($url) or die('Could not access file:
> $url');
> echo $input;
> ?>
> How can I extract only
> <resumptionToken completeListSize="14" cursor="0">set+UITO+cls
> +14+cursor+3+last+110547</resumptionToken>
>
> and put it in a variable?
>
> Thanks in advance.
> Ofuuzo
>
> ----------------------------------------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> schemaLocation="http://www.openarchives.org/OAI/2.0/
> http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
> <responseDate>2008-02-14T12:41:33Z</responseDate>
> .....
> ......
> </record>
> <resumptionToken completeListSize="14" cursor="0">set+UITO+cls
> +14+cursor+3+last+110547</resumptionToken>
> </ListRecord>
> </OAI-PMH>



$xml = new DOMDocument();
$xml->load('http://........');
$node = $xml->getElementsByTagName('resummtiontoken')->item(0);
$text = $node->nodeValue;
$listsize = $node->getAttribute('completeListSize');
$cursor = $node->getAttribute('cursor');
--
Rik Wasmus
  Réponse avec citation
Vieux 14/02/2008, 13h07   #3
ofuuzo1@yahoo.no
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Extract metadata from an xml

On 14 Feb, 13:42, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Thu, 14 Feb 2008 12:54:07 +0100, <ofuu...@yahoo.no> wrote:
> > The below xml is generated when I make a remote call like:

>
> > ?php
> > $url = "http://......./oai?
> > verb=ListRecords&metadataPrefix=frida&set=UUI";
> > $input = @file_get_contents($url) or die('Could not access file:
> > $url');
> > echo $input;
> > ?>
> > How can I extract only
> > <resumptionToken completeListSize="14" cursor="0">set+UITO+cls
> > +14+cursor+3+last+110547</resumptionToken>

>
> > and put it in a variable?

>
> > Thanks in advance.
> > Ofuuzo

>
> > ----------------------------------------------------------------------
> > <?xml version="1.0" encoding="UTF-8"?>
> > <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > schemaLocation="http://www.openarchives.org/OAI/2.0/
> >http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
> > <responseDate>2008-02-14T12:41:33Z</responseDate>
> > .....
> > ......
> > </record>
> > <resumptionToken completeListSize="14" cursor="0">set+UITO+cls
> > +14+cursor+3+last+110547</resumptionToken>
> > </ListRecord>
> > </OAI-PMH>

>
> $xml = new DOMDocument();
> $xml->load('http://........');
> $node = $xml->getElementsByTagName('resummtiontoken')->item(0);
> $text = $node->nodeValue;
> $listsize = $node->getAttribute('completeListSize');
> $cursor = $node->getAttribute('cursor');
> --
> Rik Wasmus


It does not work for php4.x.

- Ofuuzo
  Réponse avec citation
Vieux 14/02/2008, 13h12   #4
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Extract metadata from an xml

On Thu, 14 Feb 2008 14:07:15 +0100, <ofuuzo1@yahoo.no> wrote:

> On 14 Feb, 13:42, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
>> On Thu, 14 Feb 2008 12:54:07 +0100, <ofuu...@yahoo.no> wrote:
>> > The below xml is generated when I make a remote call like:

>>
>> > ?php
>> > $url = "http://......./oai?
>> > verb=ListRecords&metadataPrefix=frida&set=UUI";
>> > $input = @file_get_contents($url) or die('Could not access file:
>> > $url');
>> > echo $input;
>> > ?>
>> > How can I extract only
>> > <resumptionToken completeListSize="14" cursor="0">set+UITO+cls
>> > +14+cursor+3+last+110547</resumptionToken>

>>
>> > and put it in a variable?

>>
>> > Thanks in advance.
>> > Ofuuzo

>>
>> > ----------------------------------------------------------------------
>> > <?xml version="1.0" encoding="UTF-8"?>
>> > <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/"
>> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> > schemaLocation="http://www.openarchives.org/OAI/2.0/
>> >http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
>> > <responseDate>2008-02-14T12:41:33Z</responseDate>
>> > .....
>> > ......
>> > </record>
>> > <resumptionToken completeListSize="14" cursor="0">set+UITO+cls
>> > +14+cursor+3+last+110547</resumptionToken>
>> > </ListRecord>
>> > </OAI-PMH>

>>
>> $xml = new DOMDocument();
>> $xml->load('http://........');
>> $node = $xml->getElementsByTagName('resummtiontoken')->item(0);
>> $text = $node->nodeValue;
>> $listsize = $node->getAttribute('completeListSize');
>> $cursor = $node->getAttribute('cursor');

>
> It does not work for php4.x.


Then rewrite it using equivalent DomXml functions
(http://nl2.php.net/domxml). Seriously consider upgrading though, PHP 4 is
end of life...
--
Rik Wasmus
  Réponse avec citation
Vieux 14/02/2008, 13h54   #5
ofuuzo1@yahoo.no
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Extract metadata from an xml

On 14 Feb, 14:12, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> On Thu, 14 Feb 2008 14:07:15 +0100, <ofuu...@yahoo.no> wrote:
> > On 14 Feb, 13:42, "Rik Wasmus" <luiheidsgoe...@hotmail.com> wrote:
> >> On Thu, 14 Feb 2008 12:54:07 +0100, <ofuu...@yahoo.no> wrote:
> >> > The below xml is generated when I make a remote call like:

>
> >> > ?php
> >> > $url = "http://......./oai?
> >> > verb=ListRecords&metadataPrefix=frida&set=UUI";
> >> > $input = @file_get_contents($url) or die('Could not access file:
> >> > $url');
> >> > echo $input;
> >> > ?>
> >> > How can I extract only
> >> > <resumptionToken completeListSize="14" cursor="0">set+UITO+cls
> >> > +14+cursor+3+last+110547</resumptionToken>

>
> >> > and put it in a variable?

>
> >> > Thanks in advance.
> >> > Ofuuzo

>
> >> > ----------------------------------------------------------------------
> >> > <?xml version="1.0" encoding="UTF-8"?>
> >> > <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/"
> >> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >> > schemaLocation="http://www.openarchives.org/OAI/2.0/
> >> >http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
> >> > <responseDate>2008-02-14T12:41:33Z</responseDate>
> >> > .....
> >> > ......
> >> > </record>
> >> > <resumptionToken completeListSize="14" cursor="0">set+UITO+cls
> >> > +14+cursor+3+last+110547</resumptionToken>
> >> > </ListRecord>
> >> > </OAI-PMH>

>
> >> $xml = new DOMDocument();
> >> $xml->load('http://........');
> >> $node = $xml->getElementsByTagName('resummtiontoken')->item(0);
> >> $text = $node->nodeValue;
> >> $listsize = $node->getAttribute('completeListSize');
> >> $cursor = $node->getAttribute('cursor');

>
> > It does not work for php4.x.

>
> Then rewrite it using equivalent DomXml functions
> (http://nl2.php.net/domxml). Seriously consider upgrading though, PHP 4 is
> end of life...
> --
> Rik Wasmus


Thanks
Ofuuzo
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h53.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12879 seconds with 13 queries