Re: Converting user input for XML-validation
| From: | Zoltán Németh | Date: | Fri, 16 Nov 2007 10:23:42 +0000 |
| Subject: | Re: Converting user input for XML-validation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-264679@lists.php.net to get a copy of this message | ||
2007. 11. 16, péntek keltezéssel 11.14-kor Ralph Kutschera ezt írta:
> Hallo!
>
> I'm having an HTML-form where the user can input anything. With PHP
> I'm processing the input to XML like
>
> <userinput>what the user has entered</userinput>
>
> Now, if the user enters e.g "< thats a bracket", that gives
>
> <userinput>< thats a bracket</userinput>
>
> which of course does not validate.
>
> Is there a standard function in PHP to convert any string for usage with
> XML? In the example the string should become "< thats a bracket".
you need http://hu.php.net/htmlentities
(of course first find the part within <userinput></userinput>, thats a
quite easy regex. then use htmlentities on that part, then replace it
back to the original xml)
greets
Zoltán Németh
>
> Thanks a lot,
> Ralph
>