Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8418939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:28:03+00:00 2026-06-10T02:28:03+00:00

This is the example structure of my RSS file: <item> <title>My Title</title> <link>http://www.link.com</link> <description>The

  • 0

This is the example structure of my RSS file:

<item>
 <title>My Title</title>
 <link>http://www.link.com</link>
 <description>The description</description>
 <author>Blah Blah</author>
 <pubDate>Thu, 26 Jul 2012 10:17:15 -0400</pubDate>
 <media:content url="myimage.jpg">
  <media:title>sdafsd</media:title>
 </media:content>
 <position>1</position>
</item>

How can I remove the author tag and its contents, the entire media:content tag and its contents, and the position tag and its contents completely from the file using PHP regular expressions?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:28:05+00:00Added an answer on June 10, 2026 at 2:28 am

    My previous answer was – rightfully – removed, I should have added it as a comment. Here’s an alternative with DomDocument doing exactly what you want to do:

    <?php
    
    $xml = <<<XML
    <?xml version="1.0" encoding="UTF-8"?>
    <rss version="2.0">
      <channel>
        <title>bla</title>
        <link>bla</link>
        <description>A description</description>
        <language>en-us</language>
        <item xmlns:media="http://search.yahoo.com/mrss/">
         <title>My Title</title>
         <link>http://www.link.com</link>
         <description>The description</description>
         <author>Blah Blah</author>
         <pubDate>Thu, 26 Jul 2012 10:17:15 -0400</pubDate>
         <media:content url="myimage.jpg">
          <media:title>sdafsd</media:title>
         </media:content>
         <position>1</position>
        </item>
      </channel>
    </rss>
    XML;
    
    $doc = new DOMDocument();
    $doc->loadXml( $xml );
    
    foreach( $doc->getElementsByTagName( 'item' ) as $item ) {
        $item->removeChild( $item->getElementsByTagName( 'author' )->item( 0 ) );
        $item->removeChild( $item->getElementsByTagName( 'position' )->item( 0 ) );
                $item->removeChild( $item->getElementsByTagName( 'content' )->item( 0 ) );
    }
    
    var_dump( $doc->saveXml( ) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From this example http://www.smartclient.com/smartgwt/showcase/#tree_databinding_local , I started to implement my own tree structure dynamically
in this example http://sorgalla.com/projects/jcarousel/examples/static_controls.html i need an active state on li so it should
I need to implement a structure similar to this: example.com/folder1/folder2/folder3/../view (there can be other
See this example from RFC2518 : <D:multistatus xmlns:D=DAV:> <D:response> <D:href>http://www.foo.bar/container/</D:href> <D:propstat> <D:prop xmlns:R=http://www.foo.bar/boxschema/> <R:bigbox>
Is this possible to change bundle structure in Symfony 2, for example: MyBundle EntityName
This example working great because here containment is body http://jsfiddle.net/roXon/hMmbK/2/ when i use container
This example shows what I am trying to do: http://jsfiddle.net/Dqjvy/ I would like it
I have a file called file.txt and it has this structure: owner_name : first_last_name
I'm wondering how I can structure this example code to help avoid null pointer
I have an array that has a hierarchic structure. In this example there are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.