469,950 Members | 1,868 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

parsing tags

I have some custom tags I'm parsing, they look like this:

<edit name="some_value" name2="some_value" name3="value with spaces">

I had just been splitting on whitespace, until I though of the value
with whitespace already in it:

'/\s+/'

Is there a lightweight easy way to do this in PHP? In perl this is
neither easy and lightweight.

Jeff
Jul 28 '08 #1
2 1070
On 28 Jul, 14:15, Jeff <jeff@spam_me_not.comwrote:
* *I have some custom tags I'm parsing, they look like this:

<edit name="some_value" name2="some_value" name3="value with spaces">

I had just been splitting on whitespace, until I though of the value
with *whitespace already in it:

'/\s+/'

* *Is there a lightweight easy way to do this in PHP? In perl this is
neither easy and lightweight.

* *Jeff
How about removing the tag title and the trailing and splitting on
'/" /'?
Jul 28 '08 #2
Captain Paralytic wrote:
On 28 Jul, 14:15, Jeff <jeff@spam_me_not.comwrote:
> I have some custom tags I'm parsing, they look like this:

<edit name="some_value" name2="some_value" name3="value with spaces">

I had just been splitting on whitespace, until I though of the value
with whitespace already in it:

'/\s+/'

Is there a lightweight easy way to do this in PHP? In perl this is
neither easy and lightweight.

Jeff

How about removing the tag title and the trailing and splitting on
'/" /'?

Genius. I like that a lot.

I think I'll split on '/"\s+/'

What happens if this should occur?:

$key = '';
$key2 = ' A';

$ARRAY[$key] = 'some_val';
$ARRAY[$key2] = 'some_val';

From my code with $key2 it looks like the leading space is ignored as I
can retrieve this with: $ARRAY['A']. I'll run some more tests shortly as
I may be confused as that doesn't seem right.

Jeff
Jul 28 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Fuzzyman | last post: by
4 posts views Thread by silviu | last post: by
3 posts views Thread by djdave | last post: by
1 post views Thread by yonido | last post: by
9 posts views Thread by ankitdesai | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.