2016-04-14 105 views
0

通常我會在這個論壇上找到我所有問題的答案,但是現在我真的無法弄清楚該怎麼做。如何查找和替換2個標籤中的文字之間的字符?

我從程序中得到一個.xml文件,我們使用這個xml文件在我們的網站上創建一篇文章/產品。 從程序的輸出是這樣的:

<BigInfo>Description English: Spring washer&lt;br&gt;Descrizione Italiano: Rosetta</BigInfo> 

,我想有這樣的輸出:

<BigInfo><![CDATA[Description English: Spring washer<br>Descrizione Italiano: Rosetta]]></BigInfo> 

我媒體鏈接寫了一個腳本,用於]]></BigInfo>

取代 <BigInfo><BigInfo><![CDATA[</BigInfo>

但現在我需要將&lt;&gt;替換爲< BigInfo標籤。

我希望你們都能幫助我!

親切的問候,

公園德哈恩

+0

但從XML來看,這兩種格式是等價的。 – choroba

回答

0

什麼是你的腳本語言? PHP有例如:

http://php.net/manual/en/function.html-entity-decode.php

這不正是你想要什麼:

<?php 
$orig = "I'll \"walk\" the <b>dog</b> now"; 

$a = htmlentities($orig); 

$b = html_entity_decode($a); 

echo $a; // I'll &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; now 

echo $b; // I'll "walk" the <b>dog</b> now 
?> 
+0

很抱歉,我使用了用powershell編寫的腳本將CDATA放入我的.xml文件中。 –

+0

https://msdn.microsoft.com/en-us/library/7c5fyk1k(v=vs.100).aspx這是一個PowerShell選項 – Rene

+0

非常感謝!這會幫助我! –

相關問題