PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.smarty.general > Problem parsing xml link with _GET parameters.
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Problem parsing xml link with _GET parameters.

Réponse
 
LinkBack Outils de la discussion
Vieux 08/01/2006, 21h02   #1
Tony
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Problem parsing xml link with _GET parameters.

I tried using the following to produce xml output like the
hypothetical example...

<?php
echo '<link>www.domain.com/index.php?A=1&B=2&C=3</link>';
?>

but I found I had to substitute HTML character code like the
following to prevent xml errors...

<?php
echo '<link>www.domain.com/index.php?A#61;1&B=2&C=3</link>';
?>

Once that was accomplished I then tried to parse the above xml line with Smarty.
I expected something like...

<a href="http://www.domain.com/index.php?A=1&B=2&C=3">LINK</a>


However, when Smarty parses the file, the output is:

<a href="http://www.domain.com/index.php?A">LINK</a>
<a href="http://=">LINK</a>
<a href="http://1">LINK</a>
<a href="http://&">LINK</a>
<a href="http://B">LINK</a>
<a href="http://=">LINK</a>
<a href="http://2">LINK</a>
<a href="http://&">LINK</a>
<a href="http://C">LINK</a>
<a href="http://=">LINK</a>
<a href="http://3">LINK</a>

Smarty Parsing Functions:

function startContact($parser, $name, $attribs){
global $currentTag, $currentAttribs, $contact, $page;
$currentTag = $name;
$currentAttribs = $attribs;
switch ($name) {
case "link";
$contact .= "";
break;
}
return $contact;
}

function endContact($parser, $name){
global $currentTag, $contact, $page;
switch ($name) {
case "link";
$contact .= "";
break;
}
$currentTag = "";
$currentAttribs = "";
return $contact;
}

function dataContact($parser, $data){
global $currentTag, $contact, $page;
switch ($currentTag) {
case "link";
$contact .= "<a href=\"http://".$data."\">LINK</a>";
break;
}
return $contact;
}

Has anyone experienced this problem? How should I correct for it?
  Réponse avec citation
Vieux 09/01/2006, 06h36   #2
Denis Gerasimov
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: [SMARTY] Problem parsing xml link with _GET parameters.

Hello,

> <link>www.domain.com/index.php?A=1&B=2&C=3</link>


XML requires "&" to be encoded this way:

<link>www.domain.com/index.php?A=1&amp;B=2&amp;C=3</link>

HTH

Best regards,
Denis Gerasimov
  Réponse avec citation
Vieux 09/01/2006, 15h17   #3
Tony
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Problem parsing xml link with _GET parameters.

Changing & to &amp; (and = to =)...

<link>www.domain.com/index.php?A=1&amp;B=2&amp;C=3</link>

results in:

<a href="http://www.domain.com/index.php?A=1">LINK</a>
<a href="http://&">LINK</a>
<a href="http://B=2">LINK</a>
<a href="http://&">LINK</a>
<a href="http://C=3">LINK</a>

On 1/9/06, Denis Gerasimov <denis.gerasimov@team-force.org> wrote:
> Hello,
>
> > <link>www.domain.com/index.php?A=1&B=2&C=3</link>

>
> XML requires "&" to be encoded this way:
>
> <link>www.domain.com/index.php?A=1&amp;B=2&amp;C=3</link>
>
> HTH
>
> Best regards,
> Denis Gerasimov
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

  Réponse avec citation
Vieux 09/01/2006, 15h50   #4
messju mohr
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Problem parsing xml link with _GET parameters.

On Mon, Jan 09, 2006 at 10:17:58AM -0500, Tony wrote:
> Changing & to &amp; (and = to =)...
>
> <link>www.domain.com/index.php?A=1&amp;B=2&amp;C=3</link>
>
> results in:
>
> <a href="http://www.domain.com/index.php?A=1">LINK</a>
> <a href="http://&">LINK</a>
> <a href="http://B=2">LINK</a>
> <a href="http://&">LINK</a>
> <a href="http://C=3">LINK</a>


your business code is broken then, or maybe your xml parser. this has
hardly anything to do with smarty. if you didn't write the code that
parses your "<link>"-tag then ask the developer who did it.

> On 1/9/06, Denis Gerasimov <denis.gerasimov@team-force.org> wrote:
> > Hello,
> >
> > > <link>www.domain.com/index.php?A=1&B=2&C=3</link>

> >
> > XML requires "&" to be encoded this way:
> >
> > <link>www.domain.com/index.php?A=1&amp;B=2&amp;C=3</link>
> >
> > HTH
> >
> > Best regards,
> > Denis Gerasimov
> >
> > --
> > Smarty General Mailing List (http://smarty.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >

>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

  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 23h26.


Édité par : vBulletin® version 3.7.2
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
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,09996 seconds with 12 queries