0

I have dirty .out file which I'm converting to xml. I am cleaning it using php and then converting. I have this problem. All URLs are encoded and i need it to be in normal decoded format.

<article type="video" enterID="33">
<addedDate>2010-12-02 16:40:26</addedDate>
<thumbnail>http://eyops.com/sdfgsefgefsoio81f8b35.jpg</thumbnail>
<asset href="http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DBu927_ul_X0" addedDate="2010-12-02 16:40:23">
<duration>1500</duration>
</asset>
</article>

how do i get the href from tag, decode it and then write the output to the xml file?

Pack Hack
  • 109
  • 3
  • 13
  • possible duplicate of [Grabbing the href attribute of an A element](http://stackoverflow.com/questions/3820666/grabbing-the-href-attribute-of-an-a-element/3820783#3820783) – Gordon Jul 19 '11 at 10:03
  • possible duplicate of [How to extract a node attribute from XML using PHPs DOM parser](http://stackoverflow.com/questions/3993302/how-to-extract-a-node-attribute-from-xml-using-phps-dom-parser/3995983#3995983) – Gordon Jul 19 '11 at 10:06
  • *(reference)* http://php.net/urldecode – Gordon Jul 19 '11 at 10:07
  • possible duplicate of [saving and reading an XML file](http://stackoverflow.com/questions/3361876/saving-and-reading-a-xml-file-getting-from-the-other-url/3361906#3361906) – Gordon Jul 19 '11 at 10:08

2 Answers2

0

Parse your xml with dom, getAttribute('href') for specific nodes, create the new link decoding the current link, and set the attribute with the new link.

After that, save your edits.

http://www.w3schools.com/dom/met_element_getattribute.asp

http://www.w3schools.com/Dom/met_element_setattribute.asp

0

Use urldecode: http://php.net/manual/en/function.urldecode.php to convert. How you go about extracting and replacing in the output depends on what tools your are using for that.

Steve Claridge
  • 10,650
  • 8
  • 33
  • 35