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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:15:56+00:00 2026-06-16T06:15:56+00:00

I have this bit of xml code below and I’m trying to get the

  • 0

I have this bit of xml code below and I’m trying to get the value of all of the “result value” attributes within the results tag. The thing is…this is going to be a live feed, so there may be 1,2 or 3 result items within that tag.

Do I need to do some sort of count to see how many items are within the results tag?

<Match ct="0" id="771597" LastPeriod="2 HF" LeagueCode="19984" LeagueSort="1" LeagueType="LEAGUE" startTime="15:00" status="2 HF" statustype="live" type="2" visible="1">
    <Home id="11676" name="Manchester City" standing="1"/>
    <Away id="10826" name="Newcastle United" standing="3"/>
    <Results>
        <Result id="1" name="CURRENT" value="1-1"/>
        <Result id="2" name="FT" value="1-1"/>
        <Result id="3" name="HT" value="1-0"/>
    </Results>
    <Information>
        <league id="19984">Premier League</league>
        <note/>
        <bitarray/>
        <timestamp/>
    </Information>
</Match>

Thanks in advance

  • 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-16T06:15:57+00:00Added an answer on June 16, 2026 at 6:15 am

    SimpleXML

    Just loop through the results with SimpleXML to grab each value and name attribute, this will work with a variable number of results.

    Demo

    $obj = simplexml_load_string($xml);
    
    foreach($obj->Results->Result as $result)
    {
        echo $result->attributes()->name . ': ' . $result->attributes()->value . "\n";
    }
    

    Outputs

    CURRENT: 1-1
    FT: 1-1
    HT: 1-0

    If you have a root node such as Matches with multiple Match under it then you would use a nested foreach like so:

    foreach($obj->Match as $match)
    {
        foreach($match->Results->Result as $result)
        {
            echo $result->attributes()->name . ': ' . $result->attributes()->value . "\n";
        }
    }
    

    DOMDocument

    To do the same using DOMDocument instead of SimpleXML:

    $dom = new DOMDocument();
    $dom->loadXML($xml);
    
    foreach($dom->getElementsByTagName('Match') as $match)
    {
        foreach($match->getElementsByTagName('Result') as $result)
        {
            echo $result->getAttribute('name') . ': ' . $result->getAttribute('value') . "\n";
        }
    }
    

    Outputs the same as the SimpleXML method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this bit of code where it displays some locations from an XML
I have this bit of code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data;
i have this bit of code, it limits the Li's to 15 of them
I have this bit of code, public static List<string> GetSentencesFromWords(List<string> words, string fileContents) {
So I have this bit of code for x in range(x1,x2): for y in
I am trying to improve my jQuery skill and I have this bit of
ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js exports.routes
I use this bit of code to feed some data i have parsed from
I have this bit of code: typedef CComQIPtr<MSXML::IXMLDOMDocument2> XML_DocumentPtr; then inside some class: XML_DocumentPtr
I have this bit of code: ... var aData = request.responseXML.getElementsByTagName('data')[0]; var sDescription =

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.