Page 1 of 1

simple xml parser

Posted: Wed Mar 01, 2006 3:18 pm
by milleusi
feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Code: Select all

$book=array();
$article=0;
.....
function startElement($parser,$name,$attr){
	$GLOBALS['currentElement']=$name;	
	switch($name)
	{
	case 'author':
	$author=0;
		break;
	}
	 }

function endElement($parser,$name){ 
	global $article;
	switch($name){
	case 'article':
		$article++;
		break;
	}
}//end endElement()

/*	The character data Handler. Depending on what the currentElement is, the handler assigns the value to the appropriate variable */
function characterData($parser, $data) {
		global $article,$book;
	switch($GLOBALS["currentElement"])
		{
	case 'title':
		$book[$article]['title'].=$data;
		break;
	case 'abstract':
		$book[$article]['abstract'] .= $data;
		break;
	case 'keyword':
		$book[$article]['keyword'] .= $data;
		break;
		}
       }
and i have this kind of notes:

Notice: Undefined offset: 0 in c:\Inetpub\wwwroot\localhost\showxml.php on line 55

Notice: Undefined index: title in c:\Inetpub\wwwroot\localhost\showxml.php on line 55

Notice: Undefined index: abstract in c:\Inetpub\wwwroot\localhost\showxml.php on line 67

Notice: Undefined index: keyword in c:\Inetpub\wwwroot\localhost\showxml.php on line 70

Notice: Undefined offset: 0 in c:\Inetpub\wwwroot\localhost\showxml.php on line 58

why??
pls pls pls


feyd | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Wed Mar 01, 2006 10:01 pm
by feyd
I don't see where any of those are referenced that fit with the line numbers.

Posted: Thu Mar 02, 2006 4:11 am
by zeck
$GLOBALS['currentElement']
milleusi this coding is for post XML value...