[SOLVED] List XML elements

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

[SOLVED] List XML elements

Postby Ragnis » Tue Jan 05, 2010 5:32 am

I have the following XML:
Syntax: [ Download ] [ Hide ]
<root>
    <set key="sth" />
    <uname>Somebody</uname>
    <container>
        <uname>Somebody</uname>
        <container>
            Some content
        </container>
    </container>
    Some text
</root>


Now i need a regex to get list of the elements:
Syntax: [ Download ] [ Hide ]
root,set,uname,container

or it can be also an array.
Last edited by Ragnis on Sat Jan 23, 2010 12:42 pm, edited 1 time in total.
Image
Pointlessness
User avatar
Ragnis
Forum Commoner
 
Posts: 28
Joined: Thu Nov 13, 2008 1:35 pm
Location: Estonia

Re: List XML elements

Postby Christopher » Tue Jan 05, 2010 1:14 pm

Have you tried SimpleXML first?
(#10850)
User avatar
Christopher
Site Administrator
 
Posts: 10514
Joined: Wed Aug 25, 2004 7:54 pm
Location: Portland, Oregon, US

Re: List XML elements

Postby Ragnis » Sat Jan 23, 2010 8:24 am

I got it working myself.
Syntax: [ Download ] [ Hide ]
<([a-z:]+)(.+)?( /)?>
Image
Pointlessness
User avatar
Ragnis
Forum Commoner
 
Posts: 28
Joined: Thu Nov 13, 2008 1:35 pm
Location: Estonia


Return to Regex

Who is online

Users browsing this forum: No registered users and 1 guest