:: Forum >>

Having an href in an XML field does not show up in grid

Below is a sample XML file that includes an href in the jobname field. However, the link does not show up in the grid?

<jobs>
<job>
<startdate>09/23/07</startdate>
<enddate>09/23/07</enddate>
<jobname><a href="talent_job_details.php">National Aviation</a></jobname>
<location>Georgia World Congress Center</location>
<contact>Jim Broaderick</contact>
</job>
</jobs>

Is there any solution to this?
Fred
Tuesday, May 29, 2007
You should 'escape' html control characters inside XML -

instead of

<a href="talent_job_details.php...

it should be

&lt;a href=&quot;talent_job_details.php...
Alex (ActiveWidgets)
Wednesday, May 30, 2007
I use the following in PERL to account for the special characters which should fix your problem.

$value = "<![CDATA[$value]]>" if ($value =~ /[&'"<>]/);

In your example, this line:

<jobname><a href="talent_job_details.php">National Aviation</a></jobname>

Would be replaced with:

<![CDATA[<jobname><a href="talent_job_details.php">National Aviation</a></jobname>]]
Mike
Friday, June 1, 2007
I use the following in PERL to account for the special characters which should fix your problem.

$value = "<![CDATA[$value]]>" if ($value =~ /[&'"<>]/);

In your example, this line:

<jobname><a href="talent_job_details.php">National Aviation</a></jobname>

Would be replaced with:

<![CDATA[<jobname><a href="talent_job_details.php">National Aviation</a></jobname>]]
Mike
Friday, June 1, 2007
My appologies for the double post.

Also, I had the last line wrong...should read:

<jobname><![CDATA[<a href="talent_job_details.php">National Aviation</a>]]</jobname>
Mike
Friday, June 1, 2007
Just thought I would post my solution for PHP users:

echo "<field>".htmlentities("<a href='index.php?pagename=$link_page&$link_field=".$result->$field."'>".$result->$field."</a>")."</field>";

ends up looking like this:
<field><a href='index.php?pagename=customer_edit&id=18'>18</a></field>

htmlentities does it all for you!

Jim
Jim Nickel
Wednesday, November 7, 2007

This topic is archived.


Back to support forum

Forum search