Loko
Loko

Reputation: 6679

PHP exclude information from xml

I want to exclude just the <img> tag(ads in a newsfeed) from an xml file to be shown at my php file. I know that these should work to remove attributes but isn't there anything else to just remove the img from being shown? I think there has to be another way for this and would like to know what php function is good for this problem? (+ the information in the link doesn't work for me.)

Upvotes: 2

Views: 136

Answers (4)

Jonatan
Jonatan

Reputation: 730

Maybe this stack overflow question can be of help. Putting your xml in the $content string and regexing just as described in the top answer.

Upvotes: 1

Let me see
Let me see

Reputation: 5094

you can use a regular expression to replace the image tag......or just using the style property you can make the visibility of the image tag to hidden or display to none as it gets loaded.

Upvotes: 2

kubi
kubi

Reputation: 965

If you have a DOMDocument, you can getElementsByTagname then iterate through the list you get to removeChildren. Removing attributes won't do it.

Upvotes: -2

Use a Regular Expression to simplify things. Pass your XML content like shown.

$filtered_content = preg_replace("/<img[^>]+\>/i", "(image) ", $your_xml_content);

Upvotes: 2

Related Questions