OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] XML Problem

[ Lists Home | Date Index | Thread Index ]

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@comcast.net]
Sent: Sunday, June 30, 2002 6:19 PM
To: XML DEV
Subject: Re: [xml-dev] 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>






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS