473,750 Members | 2,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

parsing tags

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

<edit name="some_valu e" name2="some_val ue" 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 1209
On 28 Jul, 14:15, Jeff <jeff@spam_me_n ot.comwrote:
* *I have some custom tags I'm parsing, they look like this:

<edit name="some_valu e" name2="some_val ue" 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_n ot.comwrote:
> I have some custom tags I'm parsing, they look like this:

<edit name="some_valu e" name2="some_val ue" 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1582
by: Fuzzyman | last post by:
I am trying to parse an HTML page an only modify URLs within tags - e.g. inside IMG, A, SCRIPT, FRAME tags etc... I have built one that works fine using the HTMLParser.HTMLParser and it works fine.... on good HTML. Having done a google it looks like parsing dodgy HTML and having HTMLParser choke is a common theme. I would have difficulties using regular expressions as I want to modify local reference URLS as well as absolute ones.
4
2308
by: silviu | last post by:
I have the following XML string that I want to parse using the SAX parser. If I remove the portion of the XML string between the <audit> and </audit> tags the SAX is parsing correctly. Otherwise SAX wouldn't do the parsing. What's wrong with this string (between <audit> and </audit> tags)? I am using SAX/Xerces 2.3.0 on Sun 8. Thanks in advance of any help. Nick Roman <?xml version="1.0" encoding="UTF-8"?> <lyr3:L3Transaction...
3
2464
by: djdave | last post by:
My problem is that i need an algorithm parse parse HTML. For an HTML page, my script has to parse all tags to get all forms values, even if there is frame, iframe, ... How can i do such a script ? Thanks
1
2427
by: yonido | last post by:
hello, my goal is to get patterns out of email files - say "message forwarding" patterns (message forwarded from: xx to: yy subject: zz) now lets say there are tons of these patterns (by gmail, outlook, etc) - and i want to create some rules of how to get them out of the mail's html body. so at first i tried using regular expressions: for example - "any pattern that starts with a <p> and contains "from:"..." etc.
9
4061
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics" portions of Babe Ruth page (http://www.baseballprospectus.com/dt/ruthba01.shtml) and store that info in a CSV file. Also, I would like to do this for numerous players whose IDs I have stored in a text file (e.g.: cobbty01, ruthba01, speaktr01, etc.)....
0
8999
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9575
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9338
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4712
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4885
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.