光写些重要的部分

xml:

<action name="fabiao">
js('fabiao( get(ath),get(atv))');
</action>

<scene>

....

 <hotspot name="spot1" url="hotspot.png" zoom="true" scale="0.5" ath="-35" atv="+6" ondown="draghotspot();" onup="fabiao();"/>

</scene>

html:

<script>
function fabiao(x,y){

var dmtext = document.getElementsByName("pinglun")[0].value;
location.href="updateXML.php?cont="+dmtext+"&x="+x+"&y="+y;
}
</script>

php:

//添加xml节点
<?php
$cont = $_GET['cont'];
$ctime = time();
mysql_connect("127.0.0.1", "root", "root");
mysql_select_db("pinglun");
mysql_query("set names 'utf8'");
$sql_insert = "insert into think_comment (wecha_id,content,createtime) values('123456','$cont','$ctime')";
$res_insert = mysql_query($sql_insert);

$dom = new DOMDocument();
$dom->load("tour.xml");

$data_array = array(
array(
'hotspot' => '',
)
);
// 属性数组
$attribute_array = array(
'hotspot' => array(
'name' => 'name1', //此处为wecha_id
'style' => 'styleoftext222',
'keep' => 'false',
'ath' => $_GET['x'],
'atv' => $_GET['y'],
'html' => $_GET['cont'],
'ondown' => 'draghotspot();',
'seid'=>mysql_insert_id(),
)
);

这里就是节点的一些属性随便打的

//iconv("GB2312//IGNORE","UTF-8" , $attribute_array );
// 创建根节点
$item = $dom->getElementsByTagName('scene')->item(0);
foreach ($data_array as $data) {

create_item($dom, $item, $data, $attribute_array);
}
$dom->save('tour.xml');
echo"<script>history.back(-1);</script>";

function create_item($dom, $item, $data, $attribute) {
if (is_array($data)) {
foreach ($data as $key => $val) {
// 创建元素
$$key = $dom->createElement($key);
$item->appendchild($$key);
// 创建元素值
$text = $dom->createTextNode($val);
$$key->appendchild($text);
if (isset($attribute[$key])) {
// 如果此字段存在相关属性需要设置
foreach ($attribute[$key] as $akey => $row) {
// 创建属性节点
$$akey = $dom->createAttribute($akey);
$$key->appendchild($$akey);
// 创建属性值节点
$aval = $dom->createTextNode($row);
$$akey->appendChild($aval);
}
} // end if
}
} // end if
}

// end function

添加后的XML:

xml:

<action name="fabiao">
js('fabiao( get(ath),get(atv))');
</action>

<scene>

....

 <hotspot name="spot1" url="hotspot.png" zoom="true" scale="0.5" ath="-35" atv="+6" ondown="draghotspot();" onup="fabiao();"/>

 <hotspot name="a26" style="styleoftext222" keep="false" ath="-8.427214898378907" atv="0.467320266228391" html="&#x6253;&#x53D1;&#x4F3C;&#x7684;" ondown="draghotspot();"/>

</scene>