How do I add a link into an xml tag using php

897

I have an xml file that I can pull using php and display the results. I need to pick up one of the xml tags and add a link inside it so I can parse the value in the tag as a php variable. e.g.

<name>Llandaff</name>
<firmid>70330</firmid>
<branchid>2</branchid>

I want to add a link so the new xml file would be:

<name>Llandaff</name>
<firmid><a href="index.php?firmID=70330"></a></firmid>
<branchid>2</branchid>
455

Answer

Solution:

Wrap it into<![CDATA[]]>:

<firmid><![CDATA[<a href="index.php?firmID=70330"></a>]]></firmid>

To do this withsimplexml, see accepted answer in this post: How to write CDATA using SimpleXmlElement?

People are also looking for solutions to the problem: php - Getting newest newspost database

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.