i want to read xml to insert all data from xml to mysql database..who can help me..
<?
class xml_parser_model{
var $file_path;
var $data;
var $item_found;
var $id;
var $fwdName;
var $content;
var $project_name;
var $arr_convert;
var $error;
//get xml from file
function set_data($file){
$this->file_path=$file;
//read xml_file
$this->data=implode("", file($file));
}
function skip_tag(){
}
function check_error(){
}
function parse_pimpsTenderId(){
//create xml parser
$xml = xml_parser_create();
//parse xml
xml_parse_into_struct($xml, $this->data, $vals, $index);
xml_parser_free($xml);
$this->id=NULL;
$this->item_found=NULL;
//print_r($vals);
foreach($vals as $no => $item){
switch($item['tag']){
case "ID" : $this->project_name=$item['value'];
break;
case "TITLE" : $this->fwdName=$item['value'];
break;
case "DESCRIPTION" : $this->content=$item['value'];
break;
case "PROPERTY" : $this->id++;
$this->arr_convert[$this->id]['no']=$item['value'];
break;
}
}
}
function parse_dsoft(){
}
}
?>
this is my xml ;
<?php
<project>
<name>saya</name>
<state>KL</state>
<sekolah>
<kebangsaan nama="skks" state="key el">sekolah rendah</kebangsaan >
<menengah name="smknb" state="johor">sekolah menengah</menengah>
<sekolah>
<files compresser="http;//hello.my/public/resource.php?name=push$amp;id=555444222111&compressed=true">
<file name="sekolahku.pdf" path="general">http://hello.my </file>
<file name="lahirku.pdf" path="drawing">http://hello.my </file>
</files>
</project>
?>
This post has been edited by no2pencil: 06 September 2010 - 09:47 PM
Reason for edit:: Added code tags

New Topic/Question
Reply




MultiQuote



|