Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks > XML > SimpleXML
SimpleXML Forum d'entraide pour l'extension SimpleXML, qui permet de manipuler des documents XML en PHP (approche DOM).
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 12/07/2007, 09h32   #1
Invité de passage
 
Inscription : juin 2007
Messages : 4
Détails du profil
Informations forums :
Inscription : juin 2007
Messages : 4
Points : 1
Points : 1
Par défaut [SimpleXML] Activer la librairie

Bonjour,

Je débute avec le xml et php et je me pose une question.

Je viens d'installer un serveur local grâce a XAMPP 1.6.2, qui m'a fournit une version de PHP 5.2.2.Jusque là tout va bien.

Maintenant je souhaite utiliser un code en PHP utilisant des fonctions de SimpleXML tel que simplexml_load_string() mais cela ne fonctionne pas.

Je suis donc allez dans mon fichier contenant mes extensions mais le simplexml.dll n'est pas présent ni dom.dll, j'ai juste php_domxml.dll.

Après de multiple tentatives d'installation de Xampp et de Wamp5 rien n'y fait.

Ma question est donc la suivante:

Comment puis-je utiliser les fonctions SimpleXML ou bien ou trouver les dll dont j'ai besoin?

Merci d'avance pour vos réponses
Samaël63 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/07/2007, 11h14   #2
Invité de passage
 
Inscription : juin 2007
Messages : 4
Détails du profil
Informations forums :
Inscription : juin 2007
Messages : 4
Points : 1
Points : 1
Re bonjour,

Je vais vous mettre le code utilisé et les erreurs qu'il retourne ainsi cela pourra peut être vous aider a me guider.

Code :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
 
<?php
 
function search($queryString) {
	// Submit the query
	$response = file_get_contents($queryString);
	// Convert the response string to an XML object
	return simplexml_load_string($response);
}
 
function getTotalResults($feed) {
	// Get the namespaces used in the XML feed
	$ns = $feed->getNamespaces(TRUE);
	// Get the child nodes defined by the opensearch namespace
	$openSearch = $feed->children($ns['opensearch']);
	return (int) $openSearch->totalResults;  
}
 
function getSearchTerms($feed) {
	// Get the namespaces used in the XML feed
	$ns = $feed->getNamespaces(TRUE);
	// Get the child nodes defined by the opensearch namespace
	$openSearch = $feed->children($ns['opensearch']);
	// Get the Query Attributes
	$queryAttributes = $openSearch->Query->attributes();
	// Return the search terms
	return $queryAttributes->searchTerms;  
}
 
function getSpellCorrections($feed) {
	// Get the namespaces used in the XML feed
	$ns = $feed->getNamespaces(TRUE);
	// Get the child nodes defined by the opensearch namespace
	$openSearch = $feed->children($ns['opensearch']);
	// Get the Query Attributes
	foreach ($openSearch->Query as $query){
		$queryAttributes = $query->attributes();
		$corrString = (string) $queryAttributes->role;
		if ($corrString == "correction") {
			$spellCorrections[] = $queryAttributes->searchTerms;
		} 
	}	
	// Return the spell corrections
	return $spellCorrections;  
}
 
 
function getStartIndex($feed) {
	// Get the namespaces used in the XML feed
	$ns = $feed->getNamespaces(TRUE);
	// Get the child nodes defined by the opensearch namespace
	$openSearch = $feed->children($ns['opensearch']);
	return (int) $openSearch->startIndex;  
}
 
function getResults($feed, $featLinks) {
 
	$resultArray = array();
 
	// Get the namespaces used in the XML feed
	$ns = $feed->getNamespaces(TRUE);
 
	// Get the child nodes defined by the opensearch namespace
	$openSearch = $feed->children($ns['opensearch']);
 
	// Extract each entry and display results	
	foreach ($feed->entry as $entry) {
		$cat = (string)$entry->category['term'];  //check for category entry
		$catLen = strlen($cat);
		if ($featLinks == TRUE) { 
			if ($catLen == 0) // no more category entries
				break;
		}
		else if ($featLinks == FALSE) {
			if ($catLen != 0) // ignore category entry
				continue;
		}
		$result = new Result;
		$result->title = (string) $entry->title;
		$result->summary = (string) $entry->summary;
		$result->link = (string) $entry->link['href'];
		if ($featLinks == FALSE)  {
			$opensearchChild = $entry->children($ns['opensearch']);
			$result->relevance = (string) $opensearchChild->relevance;
		}
		$resultArray[] = $result;
	}
	return $resultArray;
}
 
function getSearchResults($feed) {
	$results = getResults($feed, FALSE);
	return $results;
}
 
function getFeaturedLinks($feed) {
	$results = getResults($feed, TRUE);
	return $results;
}
 
class Result {
	var $title;
	var $summary;
	var $link;
	var $relevance;
 
function getTitle() {
	return $this->title;
	}
 
function getSummary() {
	return $this->summary;
	}
 
function getLink() {
	return $this->link;
	}
 
function getRelevance() {
	return $this->relevance;
	}
}
 
 
?>
et voilà les erreurs retournées :

Citation:

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : StartTag: invalid element name in C:\webdevdata\htdocs\recherche\oye.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: <!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/st in C:\webdevdata\htdocs\recherche\oye.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in C:\webdevdata\htdocs\recherche\oye.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Extra content at the end of the document in C:\webdevdata\htdocs\recherche\oye.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: <!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/st in C:\webdevdata\htdocs\recherche\oye.php on line 31

Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in C:\webdevdata\htdocs\recherche\oye.php on line 31

Fatal error: Call to a member function getNamespaces() on a non-object in C:\webdevdata\htdocs\recherche\oye.php on line 36
Merci de m'aider a résoudre se problème.
Samaël63 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/07/2007, 11h32   #3
Membre Expert
 
Inscription : janvier 2005
Messages : 2 288
Détails du profil
Informations forums :
Inscription : janvier 2005
Messages : 2 288
Points : 2 287
Points : 2 287
Ta librairie semble chargée puisque l'erreur n'est pas "unknown function"!
Par contre c'est ton XML qui semble mal formé apparemment, peut etre pourrais-tu le montrer? (le début surtout puisqu'il a l'air de bloquer sur le début)
koopajah est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 09h51.


 
 
 
 
Partenaires

Hébergement Web