str_replace-Problem
Collapse
X
-
@Melewo
Ja, habe es noch mal verglichen. Wenn ich alles ausgebe, ist da der Satz
Code:title="Paris ‘sabotage’ will not stop talks with Öcalan"
Code:[URL="http://www.hurriyetdailynews.com/paris-sabotage-will-not-stop-talks-with-ocalan.aspx?pageID=238&nID=39002&NewsCatID=338"]Paris âsabotageâ will not stop talks with Ãcalan[/URL]
Leave a comment:
-
Originally posted by h3ll View PostDu hast noch immer ein htmlentities() drin! Hab ich dir nicht gesagt, dass du die rauswerfen sollst?
Leave a comment:
-
Eigentlich hätte es mich mehr interessiert zu erfahren, ob dann alle Schriftzeichen und Sonderzeichen richtig angezeigt werden. Kannst aber auch mal mit print_r() durchs Script gehen, nur um zu sehen, ob die Zeichen schon zu Beginn fehlerhaft ausgegeben werden und falls nicht, ab wann die Zeichen nicht korrekt ausgegeben werden.
Leave a comment:
-
Du hast noch immer ein htmlentities() drin! Hab ich dir nicht gesagt, dass du die rauswerfen sollst?
Leave a comment:
-
Keine Fehler
Außer ein paar unwesentlichen Fehlern, die ich versuche, noch wegzukriegen, habe ich dann keine Fehlerangaben.
Code:[LIST=1][*] [IMG]http://validator.w3.org/images/info_icons/error.png[/IMG] [I]Line [URL="http://validator.w3.org/check#line-8"]8[/URL], Column 16[/I]: Stray end tag html. <html lang="de"[B]>[/B] [URL="http://validator.w3.org/feedback.html?uri=;errmsg_id=html5#errormsg"]✉[/URL] [*] [IMG]http://validator.w3.org/images/info_icons/error.png[/IMG] [I]Line [URL="http://validator.w3.org/check#line-28"]28[/URL], Column 75[/I]: Bad value 100% for attribute width on element img: Expected a digit but saw % instead. …id="header"><img src="br_headeraus.png" alt="header" width="100%"[B]>[/B]</div> Syntax of non-negative integer:One or more digits (0–9). For example: 42 and 0 are valid, but -273 is not. [/LIST]
Leave a comment:
-
U+0099 <control> ist ein nicht sichtbares Steuerzeichen, wie Leerzeichen usw.. Warum das da angemeckert wird, weiß ich nicht, dachte erst wegen den anderen Zeichen, doch so einen Fehler hatte ich noch nicht.
Ich denke Du solltest Dir den Content mal gleich nach Erhalt ausgeben lassen und den restlichen Code vorübergehend mit /* Code */ deaktivieren, damit Du mal siehst, ob da auch schon Fehler zu finden sind.
PHP Code:$String = file_get_contents("http://www.hurriyetdailynews.com/");
echo htmlspecialchars($String, ENT_QUOTES);
Leave a comment:
-
nee
hat leider nix geändert, aber Danke für den Versuch. Weißt Du, was
Code:Forbidden code point U+0099.
Der komplette Fehlertext mit der entsprechenden Textzeile heißt
Code:[IMG]http://validator.w3.org/images/info_icons/error.png[/IMG] [I]Line [URL="http://validator.w3.org/check#line-84"]84[/URL], Column 405[/I]: Forbidden code point U+0099. …='_blank'>Main opposition CHPâ[B][/B]s landmark China trip begins</a></li><l…
Leave a comment:
-
Bin mir nicht sicher ob das richtig ist, da mit der 1.0 eigentlich die XML Version gemeint ist, doch probieren könntest Du es ja mal. Du erstellst ja ein neues DOM-Dokument und nicht das dabei dieser Fehler entsteht.
PHP Code:$doc = new DOMDocument("1.0", "utf-8");
Leave a comment:
-
Kompletter Code
Hier mein kompletter Code:
PHP Code:<?php
header('Content-Type: text/html; charset=utf-8');
?>
<!DOCTYPE html>
<!--[if lt IE 7 ]><html lang="de" class="no-js ie6" xmlns="http://www.w3.org/2000/xhtml"><![endif]-->
<!--[if IE 7 ]><html lang="de" class="no-js ie7" xmlns="http://www.w3.org/2000/xhtml"><![endif]-->
<!--[if IE 8 ]><html lang="de" class="no-js ie8" xmlns="http://www.w3.org/2000/xhtml"><![endif]-->
<!--[if IE 9 ]><html lang="de" class="no-js ie9" xmlns="http://www.w3.org/2000/xhtml"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="de" class="no-js" xmlns="http://www.w3.org/2000/xhtml"><!--<![endif]-->
<head>
<title>Testseite</title>
<!-- Mimic Internet Explorer 9 -->
<meta name="description" content="Die ..... international" />
<meta name="Author" content="Test" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="content-language" content="de" />
<meta name="language" content="deutsch, de" />
<link href="navi1.css" type="text/css" rel="stylesheet" media="screen" />
<link href="print3a.css" type="text/css" rel="stylesheet" media="print" />
<link rel="shortcut icon" href="http://www.nachrichtentisch.de/favicon.ico" />
</head>
<body>
<div id="alles">
<div id="header"><img src="br_headeraus.png" alt="header" width="100%"></div>
<div id="navi4">
<ul>
<li>
<a href="index.php">Home</a>
</li>
<li>
<a href="#">Ressorts</a>
<ul>
<li><a href="index.php">Politik</a></li>
<li><a href="regionales.php">Region</a></li>
<li><a href="wirtschaft.php">Wirtschaft</a></li>
<li><a href="kultur.php">Kultur</a></li>
<li><a href="wissen.php">Wissen</a></li>
<li><a href="sport.php">Sport</a></li>
</ul>
</li>
<li>
<a href="aus.php">Ausland</a>
</li>
<li>
<a href="#">Ansichten </a>
<ul>
<li><a href="aus.php">Alles</a></li>
<li><a href="aus_7.php">7 news</a></li>
<li><a href="aus_5.php">5 news</a></li>
<li><a href="aus_3.php">3 news</a></li>
<li><a href="aus_1.php">Topthema</a></li>
</ul>
</li>
<li>
<a href="impressum.php">Impressum</a>
</li>
<li>
<a href="presseschau.php">Intern</a>
</li>
</ul>
</div>
<div id="main">
<div id="col1">
<div class="border">
<a href="http://www.hurriyetdailynews.com/" target='_blank'>
<img src="logos/hudn.png" alt="Hurriyet Daily News" width="50" height="35" style=" margin:3px 0px 0px -45px ; padding:0px;"/></a>
<ul>
<?php
$data = file_get_contents('http://www.hurriyetdailynews.com/');
$doc = new DOMDocument();
$doc->loadHTML($data);
$xPath = new DOMXPath($doc);
$zaehler = 0;
foreach ($xPath->query('//h2/a') as $element)
{
$href = $element->getAttribute('href');
$hreft = "http://www.hurriyetdailynews.com" . $href;
$class = $element->getAttribute('class');
$title = str_replace('â','‘',$element->nodeValue);
$charset = 'utf-8';
$title = htmlentities($element->nodeValue, ENT_COMPAT, $charset);
/* $title = $element->getAttribute('title');*/
If ($zaehler <= 6)
{
echo "<li><a href=$hreft target='_blank'>$title</a></li>";
echo "<li><a href=\"".htmlspecialchars($hreft)."\" target='_blank'>$title</a></li>";
$zaehler++;
}
}
foreach ($xPath->query('//h1/a') as $element)
{
$href = $element->getAttribute('href');
$hreft = "http://www.hurriyetdailynews.com" . $href;
$class = $element->getAttribute('class');
$title = str_replace('""','"',$element->nodeValue);
/* $title = $element->getAttribute('title');*/
If ($zaehler <= 15)
{
/* echo "<li><a href=$hreft target='_blank'>$title</a></li>"; */
echo "<li><a href=\"".htmlspecialchars($hreft)."\" target='_blank'>$title</a></li>";
$zaehler++;
}
}
?>
</ul>
</div>
</div>
</div></div>
</body></html>
Code:Forbidden code point U+0099.
Last edited by newbie1955; 13-01-2013, 18:48.
Leave a comment:
-
Meiner Meinung nach gibst Du UTF-8 mit ISO aus.
Das entspricht ja der Iso-Ausgabe von den Tests.
Nur wie kommt das?
Leave a comment:
-
htmlspecialchars
muss Euch noch mal behelligen, heute habe ich mal die alte und neue echo-Ausgabe parallel ausgegeben, dennoch tauchte da wieder ein merkwürdiges unverdautes Sonderzeichen auf.
PHP Code:echo "<li><a href=$hreft target='_blank'>$title</a></li>";
echo "<li><a href=\"".htmlspecialchars($hreft)."\" target='_blank'>$title</a></li>";
Code:[LIST][*][URL="http://www.hurriyetdailynews.com/main-opposition--chps-landmark-china-trip-begins.aspx?pageID=238&nID=38940&NewsCatID=338"]Main opposition CHP’s landmark China trip begins[/URL][*][URL="http://www.hurriyetdailynews.com/main-opposition--chps-landmark-china-trip-begins.aspx?pageID=238&nID=38940&NewsCatID=338"]Main opposition CHP’s landmark China trip begins[/URL][/LIST]
Gruß
newbie1955
Leave a comment:
-
Du hast ein Attribut nicht in Anführungszeichen geschrieben. Und zum zweiten Fehler sagt die Fehlermeldung eigentlich eh schon alles. Man muss es nur lesen.
Leave a comment:
-
Originally posted by h3ll View PostWarum nicht einfach:PHP Code:<li>
<a href="<?php echo htmlspecialchars($hreft) ?>" target="_blank">
<?php echo htmlspecialchars($title); ?>
</a>
</li>
Auf jeden Fall Danke ich Euch herzlich für Eure Hilfe. Falls Euch noch was zu solchen Validator-Fehlern einfällt:
Code:[IMG]http://validator.w3.org/images/info_icons/error.png[/IMG] [I]Line 282, Column 142[/I]: = in an unquoted attribute value. Probable causes: Attributes running together or a URL query string in an unquoted attribute value. …http://www.cbsnews.com/video/watch/?id[B]=[/B]50138880n target='_blank'>Shelby Lynne … [IMG]http://validator.w3.org/images/info_icons/error.png[/IMG] [I]Line 7, Column 97[/I]: Bad value http://www.w3.org/2000/xhtml for the attribute xmlns (only http://www.w3.org/1999/xhtml permitted here). …l lang="de" class="no-js" xmlns="http://www.w3.org/2000/xhtml"[B]>[/B]<!--<![endif]--> [IMG]http://validator.w3.org/images/info_icons/warning.png[/IMG] [I]Line 7, Column 97[/I]: Attribute xmlns is not serializable as XML 1.0. …l lang="de" class="no-js" xmlns="http://www.w3.org/2000/xhtml"[B]>[/B]<!--<![endif]-->
Leave a comment:
-
Warum nicht einfach:PHP Code:<li>
<a href="<?php echo htmlspecialchars($hreft) ?>" target="_blank">
<?php echo htmlspecialchars($title); ?>
</a>
</li>
Leave a comment:
Leave a comment: