You are here: Re: Parsing - Reading data within a tag « PHP Programming Language « IT news, forums, messages
Re: Parsing - Reading data within a tag

Posted by Oli Filth on 10/12/05 02:04

Steve said the following on 11/10/2005 21:35:
> Some background on my problem.
> I am receiving an XML message over TCP/IP and need to access data
> within the tags of the message.
>
> Message example:
> <message title="begin"
> no="1"><description>Start</description></message>
>
>
> Now I know I can get the data from the description tag by:
>
> $xml = simplexml_load_string($xmlstr);
> echo ($xml->description[0]);
>
>
> My question is, how do I access 'title' or 'no' ?
> Is it possible?
>

http://www.php.net/simplexml

> Also, is this the best way of parsing the XML message?
>

The SimpleXML functions convert an XML document into a nested data
structure in one operation, but this could require a fair chunk of
memory, depending on the size and complexity of the XML data.

The basic XML functions, however, provide an event-based parsing scheme.
i.e. the parser reads from top to bottom, and every time an element is
opened or closed, a user-defined function is called. This allows you to
perform necessary processing without chewing up large amounts of memory.

See http://www.php.net/manual/ref.xml.php



--
Oli

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация