simple xml parser

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
milleusi
Forum Commoner
Posts: 30
Joined: Mon Jun 13, 2005 3:18 am

simple xml parser

Post 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]
Last edited by milleusi on Thu Mar 02, 2006 1:13 am, edited 2 times in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I don't see where any of those are referenced that fit with the line numbers.
zeck
Forum Newbie
Posts: 1
Joined: Thu Mar 02, 2006 4:03 am
Location: Malaysia
Contact:

Post by zeck »

$GLOBALS['currentElement']
milleusi this coding is for post XML value...
Post Reply