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

The Archive Base Latest Questions

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

I have a xml file in this format: <?xml version=1.0 encoding=ISO-8859-1?> <adp_report name=Average Draft

  • 0

I have a xml file in this format:

<?xml version="1.0" encoding="ISO-8859-1"?>
<adp_report name="Average Draft Position - Mixed 5x5" rundate="2013-01-29 17:22:10.0" begin="2013-01-26" end="2013-01-29" draftcount="126">
     <player id="500736" name="Mike Trout" position="OF" team="ANA" adp="1.66" early="1" late="4" selections="126" />
     <player id="291154" name="Ryan Braun" position="OF" team="MIL" adp="2.01" early="1" late="4" selections="126" />
     <player id="213968" name="Miguel Cabrera" position="3B" team="DET" adp="2.55" early="1" late="4" selections="126" />
</adp_report>

I need to load this into php where I will be able to access it by finding the name attribute and what the corresponding adp is. I am using it to perform some calculations and insert the results into a table that is being called from a MYSQL database. This is what I have so far:

$url = '...some url';
$xml = simplexml_load_file($url);    
while($row = mysqli_fetch_array($resultbat, MYSQLI_ASSOC))
  {
       echo "<td>" . $row['NAME'] . "</td>";
       ...print out some more player data from database...

       foreach($xml->player as $player)
            {
                $attr = $player->attributes();

                if($attr['name'] == $row['NAME']) //$row['NAME'] is the players name from my database
                {
                    $adp = (float) $attr['adp'];
                    $early = (int) $attr['early'];      

                    $stdev = -0.42+0.42*($adp-$early);
                    if($stdev<0)
                        $stdev = 1;
                    $chance =number_format(((1-NORMDIST($pickNumber,$adp,$stdev,TRUE))*100), 0);

                  echo "<td class='adp'>".$adp."</td>";
                  echo "<td class='chance'>".$chance."%</td>";
                  break;
                }
            }
}

This takes a while to process because I’m going through every row in my player database, then using foreach to look through the xml file and if I find a match I do the calculations. I have to imagine there is a more efficient way to go about this. 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-18T06:02:17+00:00Added an answer on June 18, 2026 at 6:02 am

    You could use XPath (see: SimpleXMLElement::xpath() and XPath documentation). So, instead of your foreach loop, this:

    $player = $xml->xpath('//player[@name="' . $row['NAME'] . '"]');
    if (is_array($player) && count($player)) {
        $player = $player[0];
    } else {
        continue; // not found
    }
    $attr = $player->attributes();
    // and so on...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a XML file like this <?xml version=1.0 encoding=utf-8?> <Survey Name=Aerosmith's Survey Id=S2
I have the below XML file <?xml version=1.0 encoding=iso-8859-1?> <DATASET> <TYPE>success</TYPE> <RECORD> <DATA type=email>eeee@eee.net</DATA>
I have an XML file with this format: <?xml version=1.0 encoding=utf-8 ?> <OpacResult> <valueObjects
I have an XML file with this format: <?xml version=1.0 encoding=utf-8 ?> <OpacResult> <valueObjects
I have an XML File: <?xml version=1.0 encoding=iso-8859-1?> <deadlines> <deadline> <date>2010-07-01</date> <text>Residency Application for
I have this xml file <?xml version=1.0 encoding=UTF-8?> <bo:C837ClaimParent xsi:type=bo:C837ClaimParent xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:bo=http://somelongpathHere/process/bo> <claimAux> ...
I have created an xml file like this: <?xml version=1.0 encoding=utf-8?> <ListView xmlns:android=http://schemas.android.com/apk/res/android android:layout_width=match_parent
I have an XML file looks like this: <?xml version=1.0 encoding=utf-8 ?> <PathMasks> <Mask
I have created an XML file in the following format: <?xml version=1.0 encoding=utf-8 ?>
In Eclipse (Helios) I have this XML source file: <?xml version=1.0 encoding=utf-8?> <!-- I

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.