Ich benutze DOMXPath allattributes
vom p
-Tag zu entfernen, und es funktioniert gut,Wie style Attribut nur mit DOMXPATH entfernen?
// Loop all p.
foreach($dom->getElementsByTagName("p") as $p)
{
// Loop all attributes in p.
foreach($p->attributes as $attrib)
{
// Remove all attribute from p.
$p->removeAttributeNode($attrib);
}
}
Und jetzt will ich Stilattribute
nur aus dem p-Tag entfernen.
// Loop all p.
foreach($dom->getElementsByTagName("p") as $p)
{
// Loop all attributes in p.
foreach($p->attributes as $attrib)
{
// Remove only the style attribute
$p->removeAttributeNode($p->getAttributeNode("style"));
}
}
Aber ich habe diesen Fehler im Gegenzug
Catchable fatal error: Argument 1 passed to DOMElement::removeAttributeNode() must be an instance of DOMAttr, boolean given..
Wie kann ich Stilattribute
nur entfernen?
Ihnen sehr danken. Es klappt! :-) – laukok