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 7564741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:58:23+00:00 2026-05-30T13:58:23+00:00

I need to get elements from inside a list, i catch up an update

  • 0

I need to get elements from inside a list, i catch up an update from a single wordpress page in my post.php file trough $post->post_content

The output from it is:

Sportpaleis Antwerpen 25/02/2012 Sioen De Zwerver leffinge 24/03/2012
Nathan The zydeco Cha-Chas n9 Eeklo 24/03/2012 Kraantje Pappie Nijdrop
Opwijk 24/03/2012 Eigen Makelij Hof Ter Loo Antwerpen 26/03/2012 test
testPura vida Sportpaleis Antwerpen 25/02/2012 Sioen De Zwerver
leffinge 24/03/2012 Nathan The zydeco Cha-Chas n9 Eeklo 24/03/2012
Kraantje Pappie Nijdrop Opwijk 24/03/2012 Eigen Makelij Hof Ter Loo
Antwerpen 26/03/2012

I need to find a way to get every piece of text seperatly in this list. Can i do this by putting them between div ids? and how would i adress these divs? The point is that i need to export this content to an xml. I can put contents in an xml but the problem is getting this html text into seperate variables so i can put em between those tags example:
HTML

<p id="artist">Sioen</p>
<p id="location">De Zwerver leffinge</p>
<p id="date>24/03/2012</p>

Should become: (xml)

<concerts>
<concert>
<artist>Sioen</artist>
<location>De zwerver leffinge</location>
<date>24/03/2012</date>
</concert>
.....
</concerts>

Since the comments suggest that i should put some kind of structure in i used a var_dump on the values with the <p id=""> </p> and the output is

Sioen

De Zwerver leffinge

24/03/2012
...
  • 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-05-30T13:58:24+00:00Added an answer on May 30, 2026 at 1:58 pm

    The output from it is:

    If the output is literally what you said, it’s not possible. I mean, I know that “Kraantje Pappie Nijdrop Opwijk” means that the artist is “Kraantje Pappie” and the location is “Nijdrop Opwijk”, but that’s because I’m Dutch and I happen to like “Kraantje Pappie”. Most other people wouldn’t even know where to split the string, so how do you want to tell your computer how to it?

    If the result is coming from the database, perhaps you can request it differently?

    UPDATE:

    Since the comments suggest that i should put some kind of structure in i used a var_dump on the values with the <p id=""> </p> and the output is

    Those linebreaks change everything. You can now operate under the assumption that there’s a pattern in the string: artist, break, location, break, date, break. If there’s a pattern, you can use that. Assuming that’s a format you’re always getting, you can do this quite simply:

    <?php
    $output = 'Sioen 
    
    De Zwerver leffinge
    
    24/03/2012 
    
    Nathan
    
    The zydeco Cha-Chas n9 Eeklo 
    
    24/03/2012 
    
    Kraantje Pappie 
    
    Nijdrop Opwijk 
    
    24/03/2012';
    
    /**
     * Remove empty lines.
     */
    $lines = array_map( 'trim', array_filter( explode( "\n", $output ) ) );
    
    /**
     * This is for saving the values temporarily.
     */
    $i = 0;
    $entries = array( );
    $current = array( );
    
    /**
     * Loop through all the entries.
     */
    foreach( $lines as $line ) {
        /**
         * Add the current line to the current entry.
         */
        $current[] = $line;
    
        /**
         * If $i == 2, that was the date. Add $current to the stack, and reset it's contents.
         */
        if( $i ++ === 2 ) {
            $entries[] = $current;
            $current = array( );
            $i = 0;
        }
    }
    
    /**
     * Build XML root.
     */
    $concerts = new SimpleXmlElement( '<concerts></concerts>' );
    
    /**
     * Append each entry as a concert.
     */
    foreach( $entries as $entry ) {
        $concert = $concerts->addChild( 'concert' );
    
        $concert->addChild( 'artist', array_shift( $entry ) );  
        $concert->addChild( 'location', array_shift( $entry ) );    
        $concert->addChild( 'date', array_shift( $entry ) );    
    }
    
    /**
     * Output, finally.
     */
    var_dump( $concerts->asXml( ) );
    

    That results in the following output:

    <?xml version="1.0"?>
    <concerts>
        <concert>
            <artist>Sioen</artist>
            <location>De Zwerver leffinge</location>
            <date>24/03/2012</date>
        </concert>
        <concert>
            <artist>Nathan</artist>
            <location>The zydeco Cha-Chas n9 Eeklo</location>
            <date>24/03/2012</date>
        </concert>
        <concert>
            <artist>Kraantje Pappie</artist>
            <location>Nijdrop Opwijk</location>
            <date>24/03/2012</date>
        </concert>
    </concerts>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able get a single specific attribute from an element with
i need to get a query where the elements are displayed in case the
I need a function to get the height of the highest element inside a
My question, is, whether the sequence of elements picked from a list will always
I have a list of images and I really need to get ID of
I would like to add elements to a list box on a jframe, from
I need to move the each of the h3 elements from their position below
I need to get information from the third-party application using Cocoa Accessibility API. The
I need to get neighborhood element value. HTML is <div> <input type='hidden' value='12345'> <div
I need to get the td element of a table. I do not have

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.