You are here: Re: help - isolate specific xml from mySQL entry? « All PHP « IT news, forums, messages
Re: help - isolate specific xml from mySQL entry?

Posted by noone on 02/24/06 23:21

Tommy Gildseth wrote:
> henshu wrote:
>
>
>>I wonder if its possible to "extract"/copy/parse a specific line of xml
>>from my mySQL table - isolate it from the rest of the mysql entry (on
>>PHP display)?
>>
>>example (as mySQL see's it):
>>"Today is sunny <img src="/pictures/sun.gif" /> with chances of rain
>><img src="/pictures/raincloud.jpg" width="50" alt="rain" title="rain" />
>>this evening. So you may want to carry your umbrella on your way to work."
>>
>>isolated out to:
>><img src="/pictures/sun.gif" /><img src="/pictures/raincloud.jpg"
>>width="50" alt="rain" title="rain" />
>
>
> I do not believe that will be possible using only SQL, and I'm not even sure
> it's adviseable.
> You will probably need to do some post processing with PHP. It can probably
> be done using regex, or you can use XML DOM functions to parse the XML, and
> extract all the child nodes using for ex. XPATH.
>

a very simple definition:
I think you are confusing eXendedMarkupLanuge with
HyperTextMarkupLanguage tags... HTML tags are well defined. XML uses
self-describing tags/data that uses tags NOT described in HTML.
XML always has an ending tag - HTML tags - not necessarily:

<img src="/pictures/sun.gif" />
as opposed to
<img src="/pictures/sun.gif">

XML must have a </img> tag to terminate the "parent" and/or "child"

Basically you want to troll through a long text field and extract just
the HTML tags.

and example from http://www.regular-expressions.info/examples.html
Grabbing HTML Tags

<TAG\b[^>]*>(.*?)</TAG> Analyze this regular expression with RegexBuddy
matches the opening and closing pair of a specific HTML tag. Anything
between the tags is captured into the first backreference. The question
mark in the regex makes the star lazy, to make sure it stops before the
first closing tag rather than before the last, like a greedy star would
do. This regex will not properly match tags nested inside themselves,
like in <TAG>one<TAG>two</TAG>one</TAG>.

<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1> Analyze this regular expression with
RegexBuddy will match the opening and closing pair of any HTML tag. Be
sure to turn off case sensitivity. The key in this solution is the use
of the backreference \1 in the regex. Anything between the tags is
captured into the second backreference. This solution will also not
match tags nested in themselves.

 

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

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