Hi,
I have defined a set of custom tags that I put among regular HTML tags. E.g.
<body>
<div id="regular_id" >
<namespace:cont ainer id="something" type="article" />
</div>
</body>
At this time, I use PHP preg_* functions to parse the HTML file and trigger actions when I detect a tag that starts with the string...
User Profile
Collapse
-
Validate (X)HTML with custom tags with PHP DOM API
-
I tried but it still doesn't work.
mb_detect_encod ing($str.'a', 'ISO-8859-1,UTF-8')
does not return the same value than
mb_detect_encod ing($str.'a', 'UTF-8,ISO-8859-1')
When I output debug messages, it looks like that strings that I send back to the server and the strings returned from the server are the same...
Aaaargh !!! it is getting on my nerves -
-
-
I tried this when I used DOM::loadHTML to query the HTML for the data but the problem remains the same :
When I send back the data to the server (through HTTP POST), it seems that the data are corrupted.
Note that my script does not print out and executes on the command line.Leave a comment:
-
Does PHP send out corrupted string ? (charset issue)
Hi,
I fetch web pages using Zend_Http (I send out POST data, fetch the results, and so on)
I have no problem with that.
I did a mb_detect_encod ing() of the returned HTML and the function says it's UTF-8 encoded.
Parts of the returned HTML must be send back to the server. I store these parts into PHP strings.
The problem is that when I send back these PHP strings, all special characters... -
I wrote that script to extract all email addresses contained into a file : (don't forget to replace page.html with your file)
[php]
<?php
$buffer=file_ge t_contents('pag e.html');
/* pas de ^ et $ car plusieurs emails par lignes !*/
$regex='`([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})`';
$matches=array( );
preg_match_all( $regex, $buffer,...Leave a comment:
-
Hi,
I use the following regular expression to extract emails from files :
^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$
source : http://www.developer.com/lang/php/article.php/3290141Leave a comment:
-
We use PHPMailer in several projects and we never have that kind of issues. But we like to keep things simple.
Do you use the last version of PHPMailer ? Are you sure that your SMTP server is configured correctly ?
That is weird.Leave a comment:
-
Personaly :
I would first have a look at the complexity of the xml structure. If it's too simple, I would loop into it with just the dom api and I generate the html "by hand".
If it is not (like 2 or more depth levels), I go DOM+XSLT without hesitation.
In both cases I try to save the result (the outputted html) into a file in order to avoid unecessary processing.Leave a comment:
-
Try this :
[php]
$PHPMailer->SMTPAuth = true;
$PHPMailer->SMTPSecure = "ssl";
[/php]
Also, set $PHPMailer->Port with the correct port value if necessary.Leave a comment:
-
You should not use this <?=$var?> (on its way to deprecation), but this <?php echo $var; ?> instead....Leave a comment:
-
Did you have a look at Zend Framework ? The Zend_Http could help, but you need PHP5...Leave a comment:
-
I had a one month mission in a public administration that uses php-nuke. They needed new tailored modules to be integrated into the cms.
I can't remember what version of php-nuke it was but I can tell you this :
The code was so bad that each line of it can be reported at thedailywtf.com ! The developer didn't even know what OOP is because I've seen none in the cms core !
My advise : don't rely on itLeave a comment:
-
A simple output does the job :
[php]
<script type="text/javascript">
function hello(name) {
alert("hello "+name);
}
<?php
while ( $rec = mysql_fetch_ass oc($query) ) {
echo 'hello("',$rec['firstname'],'");', "\n";
}
?>
// or
hello("<?php echo $var; ?>");
...Leave a comment:
-
I don't know much about DocBook but you might want to look at it.Leave a comment:
-
I don't understand what your problem is now... not only <p> tag hold texts. <li>, <td>, <span> and more also do....Leave a comment:
-
These are "just" warnings resulting in wrong or unsupported html entities or something else. It's just impossible to parse a html document without getting these warnings...
If your texts are not between <p></p>, you can replace //p by //td. Like I said, you need to adapt it to your needs.Leave a comment:
-
If you are using the header() func to redirect make sure that you do not output anything before that.
If you open a connection to a database before the call to header() and that the connection fails, the error message echoed by php will bug the call to header() too.Leave a comment:
-
If you are working with PHP5, you can use the DOM API for that.
Adapt this to your needs :
[php]
<?php
$htmlString = file_get_conten ts('url_or_path _to_html_file') ;
$htmlDoc = DOMDocument::lo adHTML($htmlStr ing);
$xpath = new DOMXPath($htmlD oc);
/* fetch the content of all <p> tags */
$pNodesList = $xpath->query('//p');
for ($i=0; $i<$pNodesList->length;...Leave a comment:
No activity results to display
Show More
Leave a comment: