Hello.
Selkirk, your parser works really great. I have used it for the form validation again and have something working now. Altough, I don't know how well the implementation is ...
--------------------------------------------------------
This is an example of a form which uses custom tags and filters:
This doesn't look bad in Dreamweaver eitherPHP Code:<form method="post" action="http://localhost/sitepoint/xmlparsertest.php">
<table>
<tr>
<td>name:</td>
<td>
<webform:textbox name="name" length="20">
<webform:filter type="LengthFilter" max="20" />
</webform:textbox>
</td>
<td style="color: #cc0000;"><webform:error /></td>
</tr>
<tr>
<td>email:</td>
<td>
<webform:textbox name="email" length="30">
<webform:filter type="RegExpFilter" regexp="#.+?@.+?\.(de|com|co\.uk)#" />
<webform:filter type="LengthFilter" min="8" max="30" />
</webform:textbox>
</td>
<td style="color: #cc0000;"><webform:error /></td>
</tr>
<tr>
<td>telephone</td>
<td>
<webform:textbox name="phone" length="20">
<webform:filter type="RegExpFilter" regexp="#0\d{2,4}(-|/)\d{3,}#" />
</webform:textbox>
</td>
<td style="color: #cc0000;"><webform:error /></td>
</tr>
<tr>
<td colspan="3" align="center">
<input type="submit" name="submit" value="Validate" />
</td>
</tr>
</table>
</form>
![]()
The textbox tag is firstly used to display the <input type=text> part and secondly used to create the field for the validator. The <webform:error /> tag is filled out if the form has been submitted and the validation failed.
I have attached the source of a working example. If someones wants to test this, it is best to extract it to a folder called "sitepoint" and keep the file structure of the zip file.
Edit:
Because I included Selkirk's parser without any reference, I changed the zip file. Thus if someone wants to test the examples, you also need to download Selkirk's parser from here:
http://www.sitepointforums.com/showp...6&postcount=15
Because of some require_once calls in the source files it would be easiest to save the above file as XMLParser.php in the folder XML where the other classes are located.



. If you could force the pointer advance that would solve the infinite loop problem. Hmm....


Just had to have a laugh...
****() is hunting for a quote with scanUntilString(), the method also gets a list of characters to "brake" on, such as < > and apostrophe. Couldn't see an obvious way to do it staight away though without some very clunky code.


Bookmarks