- //--------------------------------------------------------------
- // xmlを連想配列で返す
- // php変数不可文字対応 英数字以外はすべて_へ変換
- //--------------------------------------------------------------
- function simplexml_load_string2array($xmlstr){
- // 不正文字コードの除去
- $res=preg_match_all("/<([^>]+)>/i",$xmlstr,$matches);
- $tags=$matches[1];
- for($i=0;$i<count($tags)-1;$i++){ ペアタグのとき="" if('="" '.$tags[$i]="=$tags[$i+1]){" $replaced="preg_replace("/[^0-9a-zA-Z_]+/","_",$tags[$i]);" 英数字_以外有り="" if($tags[$i]!="$replaced){" $xmlstr="str_replace($tags[$i],$replaced,$xmlstr);" }="" ペア分次スキップ="" $i++;="" $xml="simplexml_load_string($xmlstr);" true);="" return="" $xml;="" <="" pre="">
- <div style="clear: both;"></div>
- </count($tags)-1;$i++){>
2015年3月11日水曜日
xml変換
登録:
投稿 (Atom)