What’s The Regex For The Following? (PHP)?
PHP / MySQL, Regular Expressions February 22nd, 2009I want to do a
preg_split to get all the subnodes of the following in an array. I want to match everything between the <Subscriber> tags, but note that the first has XMLNS.
<Subscriber xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<EmailAddress>inetmjr@gmail.com</EmailAddress>
<Name>MJR</Name>
<Date>2008-04-11 15:00:00</Date>
<State>Active</State>
<CustomFields />
</Subscriber>
<Subscriber>
<EmailAddress>mreeves@gmail.com</EmailAddress>
<Name>Mark Reeves</Name>
<Date>2008-04-11 14:37:00</Date>
<State>Active</State>
<CustomFields />
</Subscriber>
What’s the regex to use with preg_split to get <Email> through <CustomFields/> into array nodes?
Thanks!
Mark
Hi Mark,
Is there some reason in particular you want to do this with regex instead of using one of the xml library classes? It’d be pretty easy to make a SimpleXML object from that snippet and extract the data from there.
Is there some reason in particular you want to do this with regex instead of using one of the xml library classes? It’d be pretty easy to make a SimpleXML object from that snippet and extract the data from there.