[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XML Problem


.xml problem
Ok well I am using SAX/expat for this particular document. Anyway, I am not
sure if you know PHP or not but here is how I would process it:

<?PHP
	function charcterPro($parser, $data)
	{
		global $TAG;

		switch ($currentTag)
	{
	case "TAG1":
	$TAG  =  $data;
	break;

	default:
	break;
	}
}

?>

That will get "SOME TEXT" into the variable tag, but as I stated before it
will not work in cases such as example 1.


-----Original Message-----
From: Thomas B. Passin [mailto:tpassin@c...]
Sent: Sunday, June 30, 2002 6:19 PM
To: XML DEV
Subject: Re:  XML Problem

[Sebastian A]

> I am having some problems parsing XML with PHP. Here is an example of my
> problem:
> Example 1:
>
> <PAGE>
> <TAG1>
> SOME TEXT
> </TAG1>
> </PAGE>
>

You do not say how you are trying to process the xml file.  Typically
programs run into trouble like this because they think that the text will
all be delivered in one node (for DOM) or one callback (for SAX).  But that
would be a poor assumption.  The text may actually be delivered in several
chunks.  In this case, you might get [NEWLINE]SOME TEXT[NEWLINE].

Whether SAX, DOM or some other system, you must always make sure that you
collect (or traverse) all pieces that could contain the character data of an
element.

Cheers,

Tom P



-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://lists.xml.org/ob/adm.pl>



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.