Link to home
Create AccountLog in
Avatar of kennedypd1
kennedypd1

asked on

xml to php

Hi

I am sure this is simple but I have confussed myself I think.

I have the xml file and with a php file I want to have a form that has

Section name
ConstructName
Total

ConstructName
Total

ConstructName
Total

ConstructName
Total

ConstructName
Total



Section name
ConstructName
Total

ConstructName
Total

ConstructName
Total

ConstructName
Total

ConstructName
Total

At the moment I have this php code but it lists all the constructs in the xml file not just the ones inside the section name.

Not sure if this is too clear but ask away if you need more info from me.

 
PHP CODE

$completeurl ="http://www.pathtoxmlfile";

$xml = simplexml_load_file($completeurl);

$testname = $xml->AssessmentDetails->Assessment;
$testdate = $xml->AssessmentDetails->TimeSubmitted;
$testperson = $xml->AssessmentDetails->Person;
$sectionname = $xml->AssessmentResults->Section->SectionID->SectionName;

echo  "$testname";
echo  "$testdate";
echo  "$testperson";
echo "$sectionname";


$constructs = $xml->xpath('/AssessmentResult/AssessmentResults/Section/SectionConstructs/Construct');

foreach ($xml->AssessmentResults->Section as $section) {
  echo "<h2>" . $section->SectionName . "</h2>";

foreach ($constructs as $construct) {
  echo "<h3>  {$construct->ConstructName} </h3>";
  echo "<p>  {$construct->Total}  </p>";
}



XML FILE

-<AssessmentResults>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
-<Section>
<SectionID>8</SectionID>
<SectionName>Leadership Dynamics</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>71</ConstructID>
<ConstructName>Leadership Ability</ConstructName>
<IsPositive>positive</IsPositive>
<Total>69</Total>
</Construct>
-<Construct>
<ConstructID>73</ConstructID>
<ConstructName>Commitment</ConstructName>
<IsPositive>positive</IsPositive>
<Total>64</Total>
</Construct>
-<Construct>
<ConstructID>77</ConstructID>
<ConstructName>Listening Skills</ConstructName>
<IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
-<Construct>
<ConstructID>80</ConstructID>
<ConstructName>Problem Solving Ability</ConstructName> <IsPositive>positive</IsPositive>
<Total>69</Total>
</Construct>
-<Construct>
<ConstructID>86</ConstructID>
<ConstructName>Interpersonal</ConstructName>
<IsPositive>positive</IsPositive>
<Total>66</Total>
</Construct>
</SectionConstructs>
</Section>
-<Section>
<SectionID>9</SectionID>
<SectionName>Task Orientated Qualities</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>74</ConstructID>
<ConstructName>Communication Skills</ConstructName> <IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
-<Construct>
<ConstructID>78</ConstructID>
<ConstructName>Passion</ConstructName>
<IsPositive>positive</IsPositive>
<Total>48</Total>
</Construct>
</SectionConstructs>
</Section>
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

I think we need you to distill this question down to the SSCCE.  The XML document posted with the question is invalid.  To see why, install this and run it.

<?php // RAY_temp_kennedypd1.php
error_reporting(E_ALL);
echo '<pre>';

$xml = <<<EOD
<AssessmentResults>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
-<Section>
<SectionID>8</SectionID>
<SectionName>Leadership Dynamics</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>71</ConstructID>
<ConstructName>Leadership Ability</ConstructName>
<IsPositive>positive</IsPositive>
<Total>69</Total>
</Construct>
-<Construct>
<ConstructID>73</ConstructID>
<ConstructName>Commitment</ConstructName>
<IsPositive>positive</IsPositive>
<Total>64</Total>
</Construct>
-<Construct>
<ConstructID>77</ConstructID>
<ConstructName>Listening Skills</ConstructName>
<IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
-<Construct>
<ConstructID>80</ConstructID>
<ConstructName>Problem Solving Ability</ConstructName> <IsPositive>positive</IsPositive>
<Total>69</Total>
</Construct>
-<Construct>
<ConstructID>86</ConstructID>
<ConstructName>Interpersonal</ConstructName>
<IsPositive>positive</IsPositive>
<Total>66</Total>
</Construct>
</SectionConstructs>
</Section>
-<Section>
<SectionID>9</SectionID>
<SectionName>Task Orientated Qualities</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>74</ConstructID>
<ConstructName>Communication Skills</ConstructName> <IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
-<Construct>
<ConstructID>78</ConstructID>
<ConstructName>Passion</ConstructName>
<IsPositive>positive</IsPositive>
<Total>48</Total>
</Construct>
</SectionConstructs>
</Section>
EOD;

$obj = simpleXML_Load_String($xml);

Open in new window

Please post back with a good test case, thanks, ~Ray
Avatar of kennedypd1
kennedypd1

ASKER

Hi

I didnt put the entire xml file up which is what I think you are asking for so here it is.
Hope this is what you are after

<?xml version="1.0" encoding="UTF-8"?>
-<AssessmentResult>
-<AssessmentDetails>
<AssessmentID>2052</AssessmentID>
<Assessment>The Edge</Assessment>
<TimeSubmitted>Mon, 10 Dec 2012. 13:55</TimeSubmitted>
<Person>Mr. Paul P Kennedy</Person>
<Organization>Edge</Organization>
</AssessmentDetails>
-<AssessmentResults>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
-<Section>
<SectionID>8</SectionID>
<SectionName>Leadership Dynamics</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>71</ConstructID>
<ConstructName>Leadership Ability</ConstructName>
<IsPositive>positive</IsPositive>
<Total>69</Total>
</Construct>
-<Construct>
<ConstructID>73</ConstructID>
<ConstructName>Commitment</ConstructName>
<IsPositive>positive</IsPositive>
<Total>64</Total>
</Construct>
-<Construct>
<ConstructID>77</ConstructID>
<ConstructName>Listening Skills</ConstructName>
<IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
-<Construct>
<ConstructID>80</ConstructID>
<ConstructName>Problem Solving Ability</ConstructName> <IsPositive>positive</IsPositive>
<Total>69</Total>
</Construct>
-<Construct>
<ConstructID>86</ConstructID>
<ConstructName>Interpersonal</ConstructName>
<IsPositive>positive</IsPositive>
<Total>66</Total>
</Construct>
</SectionConstructs>
</Section>
-<Section>
<SectionID>9</SectionID>
<SectionName>Task Orientated Qualities</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>74</ConstructID>
<ConstructName>Communication Skills</ConstructName> <IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
-<Construct>
<ConstructID>78</ConstructID>
<ConstructName>Passion</ConstructName>
<IsPositive>positive</IsPositive>
<Total>48</Total>
</Construct>
</SectionConstructs>
</Section>
-<Section>
<SectionID>10</SectionID>
<SectionName>Self Orientated Qualities</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>82</ConstructID>
<ConstructName>Self - Discipline</ConstructName>
<IsPositive>positive</IsPositive>
<Total>56</Total>
</Construct>
-<Construct>
<ConstructID>79</ConstructID>
<ConstructName>Positive Attitude</ConstructName>
<IsPositive>positive</IsPositive>
<Total>64</Total>
</Construct>
</SectionConstructs>
</Section>
<Section/>
<Section/>
-<Section>
<SectionID>13</SectionID>
<SectionName>Personal Values</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>49</ConstructID>
<ConstructName>Ability Utilization</ConstructName>
<IsPositive>positive</IsPositive>
<Total>90</Total>
</Construct>
-<Construct>
<ConstructID>65</ConstructID>
<ConstructName>Personal Development</ConstructName> <IsPositive>positive</IsPositive>
<Total>85</Total>
</Construct>
-<Construct>
<ConstructID>59</ConstructID>
<ConstructName>Personal Standards</ConstructName>
<IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
-<Construct>
<ConstructID>57</ConstructID>
<ConstructName>Risk</ConstructName>
<IsPositive>positive</IsPositive>
<Total>61</Total>
</Construct>
-<Construct>
<ConstructID>47</ConstructID>
<ConstructName>Character Qualities</ConstructName>
<IsPositive>positive</IsPositive>
<Total>61</Total>
</Construct>
</SectionConstructs>
</Section>
-<Section>
<SectionID>14</SectionID>
<SectionName>Money Values</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>58</ConstructID>
<ConstructName>Financial Guarantee</ConstructName>
<IsPositive>positive</IsPositive>
<Total>75</Total>
</Construct>
-<Construct>
<ConstructID>54</ConstructID>
<ConstructName>Financial Compensation</ConstructName> <IsPositive>positive</IsPositive>
 <Total>90</Total>
</Construct>
-<Construct>
<ConstructID>56</ConstructID>
<ConstructName>Status</ConstructName>
<IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
</SectionConstructs>
</Section>
-<Section>
<SectionID>15</SectionID>
<SectionName>People Values</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>50</ConstructID>
<ConstructName>Interest in People</ConstructName>
<IsPositive>positive</IsPositive>
<Total>76</Total>
</Construct>
-<Construct>
<ConstructID>62</ConstructID>
<ConstructName>Social Interaction</ConstructName>
<IsPositive>positive</IsPositive>
<Total>56</Total>
</Construct>
-<Construct>
<ConstructID>68</ConstructID>
<ConstructName>Servanthood</ConstructName>
<IsPositive>positive</IsPositive>
<Total>57</Total>
</Construct>
</SectionConstructs>
</Section>
-<Section>
<SectionID>16</SectionID>
<SectionName>Environmental Values</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>55</ConstructID>
<ConstructName>Freedom Of Lifestyle</ConstructName>
<IsPositive>positive</IsPositive>
<Total>73</Total>
</Construct>
-<Construct>
<ConstructID>64</ConstructID>
<ConstructName>Predictable Environment</ConstructName> <IsPositive>positive</IsPositive>
<Total>64</Total>
</Construct>
-<Construct>
<ConstructID>153</ConstructID>
<ConstructName>Repetitiveness</ConstructName>
<IsPositive>positive</IsPositive>
<Total>41</Total>
</Construct>
-<Construct>
<ConstructID>60</ConstructID>
<ConstructName>Cultural Prejudice</ConstructName>
<IsPositive>positive</IsPositive>
<Total>49</Total>
</Construct>
</SectionConstructs>
</Section>
-<Section>
<SectionID>17</SectionID>
<SectionName>Leadership Values</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>69</ConstructID>
<ConstructName>Result Orientation</ConstructName>
<IsPositive>positive</IsPositive>
<Total>72</Total>
</Construct>
-<Construct>
<ConstructID>51</ConstructID>
<ConstructName>Autonomy</ConstructName>
<IsPositive>positive</IsPositive>
<Total>92</Total>
</Construct>
-<Construct>
<ConstructID>52</ConstructID>
<ConstructName>Authority</ConstructName>
<IsPositive>positive</IsPositive>
<Total>83</Total>
</Construct>
-<Construct>
<ConstructID>66</ConstructID>
<ConstructName>Challenging Attributes</ConstructName>
 <IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
-<Construct>
<ConstructID>67</ConstructID>
<ConstructName>Multi Tasking</ConstructName>
<IsPositive>positive</IsPositive>
<Total>52</Total>
</Construct>
</SectionConstructs>
</Section>
-<Section>
<SectionID>18</SectionID>
<SectionName>Physical Values</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>70</ConstructID>
<ConstructName>Physical Challenges</ConstructName>
<IsPositive>positive</IsPositive>
<Total>41</Total>
</Construct>
-<Construct>
<ConstructID>63</ConstructID>
<ConstructName>Physical Activities</ConstructName>
<IsPositive>positive</IsPositive>
<Total>49</Total>
</Construct>
</SectionConstructs>
</Section>
-<Section>
<SectionID>19</SectionID>
<SectionName>Artistic Values</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>61</ConstructID>
<ConstructName>Artistic Appreciation</ConstructName>
<IsPositive>positive</IsPositive>
<Total>73</Total>
</Construct>
-<Construct>
<ConstructID>53</ConstructID>
<ConstructName>Originality</ConstructName>
<IsPositive>positive</IsPositive>
<Total>97</Total>
</Construct>
</SectionConstructs>
</Section>
-<Section>
<SectionID>20</SectionID>
<SectionName>Fields of Interest</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>116</ConstructID>
<ConstructName>General Culture</ConstructName>
<IsPositive>positive</IsPositive>
<Total>38</Total>
</Construct>
-<Construct>
<ConstructID>117</ConstructID>
<ConstructName>Entrepreneur</ConstructName>
<IsPositive>positive</IsPositive>
<Total>85</Total>
</Construct>
-<Construct>
<ConstructID>118</ConstructID>
<ConstructName>Business Interaction</ConstructName>
<IsPositive>positive</IsPositive>
<Total>75</Total>
</Construct>
-<Construct>
<ConstructID>119</ConstructID>
<ConstructName>Technology</ConstructName>
<IsPositive>positive</IsPositive>
<Total>99</Total>
</Construct>
-<Construct>
<ConstructID>130</ConstructID>
<ConstructName>Marketing</ConstructName>
<IsPositive>positive</IsPositive>
<Total>87</Total>
</Construct>
-<Construct>
<ConstructID>115</ConstructID>
<ConstructName>Service</ConstructName>
<IsPositive>positive</IsPositive>
<Total>49</Total>
</Construct>
-<Construct>
<ConstructID>131</ConstructID>
<ConstructName>Research</ConstructName>
<IsPositive>positive</IsPositive>
<Total>70</Total>
</Construct>
-<Construct>
<ConstructID>129</ConstructID>
<ConstructName>Aeronautics</ConstructName>
<IsPositive>positive</IsPositive>
<Total>45</Total>
</Construct>
-<Construct>
<ConstructID>127</ConstructID>
<ConstructName>Administration</ConstructName>
<IsPositive>positive</IsPositive>
<Total>57</Total>
</Construct>
-<Construct>
<ConstructID>126</ConstructID>
<ConstructName>Training</ConstructName>
<IsPositive>positive</IsPositive>
<Total>75</Total>
</Construct>
-<Construct>
<ConstructID>125</ConstructID>
<ConstructName>Medical</ConstructName>
<IsPositive>positive</IsPositive>
<Total>33</Total>
</Construct>
-<Construct>
<ConstructID>124</ConstructID>
<ConstructName>Mechanical</ConstructName>
<IsPositive>positive</IsPositive>
<Total>40</Total>
</Construct>
-<Construct>
<ConstructID>123</ConstructID>
<ConstructName>Entertainment</ConstructName>
<IsPositive>positive</IsPositive>
<Total>56</Total>
</Construct>
-<Construct>
<ConstructID>122</ConstructID>
<ConstructName>Arts</ConstructName>
<IsPositive>positive</IsPositive>
<Total>83</Total>
</Construct>
-<Construct>
<ConstructID>128</ConstructID>
<ConstructName>Human Resources</ConstructName>
<IsPositive>positive</IsPositive>
<Total>68</Total>
</Construct>
-<Construct>
<ConstructID>120</ConstructID>
<ConstructName>Science</ConstructName>
<IsPositive>positive</IsPositive>
<Total>66</Total>
</Construct>
-<Construct>
<ConstructID>121</ConstructID>
<ConstructName>Outdoors</ConstructName>
<IsPositive>positive</IsPositive>
<Total>45</Total>
</Construct>
</SectionConstructs>
</Section>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
</AssessmentResults>
</AssessmentResult>
I have shortened the xml file and it is below. Also under that I have the results as I want the php file to display them. Hope this is clearer.

<?xml version="1.0" encoding="UTF-8"?>
-<AssessmentResult>
-<AssessmentDetails>
<AssessmentID>2052</AssessmentID>
<Assessment>The Edge Career Planning Inven</Assessment>
<TimeSubmitted>Mon, 10 Dec 2012. 13:55</TimeSubmitted>
<Person>Mr. Paul P Kennedy</Person>
<Organization>The Edge BT</Organization>
</AssessmentDetails>
-<AssessmentResults>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
-<Section>
<SectionID>8</SectionID>
<SectionName>Leadership Dynamics</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>71</ConstructID>
<ConstructName>Leadership Ability</ConstructName>
<IsPositive>positive</IsPositive>
<Total>69</Total>
</Construct>
-<Construct>
<ConstructID>73</ConstructID>
<ConstructName>Commitment</ConstructName>
<IsPositive>positive</IsPositive>
<Total>64</Total>
</Construct>
-<Construct>
<ConstructID>77</ConstructID>
<ConstructName>Listening Skills</ConstructName>
<IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
</SectionConstructs>
</Section>
-<Section>
<SectionID>9</SectionID>
<SectionName>Task Orientated Qualities</SectionName>
<IsPositive>positive</IsPositive>
-<SectionConstructs>
-<Construct>
<ConstructID>74</ConstructID>
<ConstructName>Communication Skills</ConstructName>
<IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
-<Construct>
<ConstructID>78</ConstructID>
<ConstructName>Passion</ConstructName>
<IsPositive>positive</IsPositive>
<Total>48</Total>
</Construct>
</SectionConstructs>
</Section>
</SectionConstructs>
</Section>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
</AssessmentResults>
</AssessmentResult>









Leadership Dynamics


Leadership Ability          69
Commitment                  64
Listening Skills                71

Task Orientated Qualities  

 

Communication Skills    71
Passion                            48
The most recent XML document will not parse, either.  I used the larger one in the middle to get this script working.  
http://www.laprbass.com/RAY_temp_kennedypd1.php

<?php // RAY_temp_kennedypd1.php
error_reporting(E_ALL);
echo '<pre>';


// LOOKING FOR SOMETHING LIKE THIS...
/*
Leadership Dynamics

Leadership Ability      69
Commitment              64
Listening Skills        71

Task Orientated Qualities

Communication Skills    71
Passion                 48
*/

$xml = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<AssessmentResult>
<AssessmentDetails>
<AssessmentID>2052</AssessmentID>
<Assessment>The Edge</Assessment>
<TimeSubmitted>Mon, 10 Dec 2012. 13:55</TimeSubmitted>
<Person>Mr. Paul P Kennedy</Person>
<Organization>Edge</Organization>
</AssessmentDetails>
<AssessmentResults>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section>
<SectionID>8</SectionID>
<SectionName>Leadership Dynamics</SectionName>
<IsPositive>positive</IsPositive>
<SectionConstructs>
<Construct>
<ConstructID>71</ConstructID>
<ConstructName>Leadership Ability</ConstructName>
<IsPositive>positive</IsPositive>
<Total>69</Total>
</Construct>
<Construct>
<ConstructID>73</ConstructID>
<ConstructName>Commitment</ConstructName>
<IsPositive>positive</IsPositive>
<Total>64</Total>
</Construct>
<Construct>
<ConstructID>77</ConstructID>
<ConstructName>Listening Skills</ConstructName>
<IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
<Construct>
<ConstructID>80</ConstructID>
<ConstructName>Problem Solving Ability</ConstructName> <IsPositive>positive</IsPositive>
<Total>69</Total>
</Construct>
<Construct>
<ConstructID>86</ConstructID>
<ConstructName>Interpersonal</ConstructName>
<IsPositive>positive</IsPositive>
<Total>66</Total>
</Construct>
</SectionConstructs>
</Section>
<Section>
<SectionID>9</SectionID>
<SectionName>Task Orientated Qualities</SectionName>
<IsPositive>positive</IsPositive>
<SectionConstructs>
<Construct>
<ConstructID>74</ConstructID>
<ConstructName>Communication Skills</ConstructName> <IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
<Construct>
<ConstructID>78</ConstructID>
<ConstructName>Passion</ConstructName>
<IsPositive>positive</IsPositive>
<Total>48</Total>
</Construct>
</SectionConstructs>
</Section>
<Section>
<SectionID>10</SectionID>
<SectionName>Self Orientated Qualities</SectionName>
<IsPositive>positive</IsPositive>
<SectionConstructs>
<Construct>
<ConstructID>82</ConstructID>
<ConstructName>Self - Discipline</ConstructName>
<IsPositive>positive</IsPositive>
<Total>56</Total>
</Construct>
<Construct>
<ConstructID>79</ConstructID>
<ConstructName>Positive Attitude</ConstructName>
<IsPositive>positive</IsPositive>
<Total>64</Total>
</Construct>
</SectionConstructs>
</Section>
<Section/>
<Section/>
<Section>
<SectionID>13</SectionID>
<SectionName>Personal Values</SectionName>
<IsPositive>positive</IsPositive>
<SectionConstructs>
<Construct>
<ConstructID>49</ConstructID>
<ConstructName>Ability Utilization</ConstructName>
<IsPositive>positive</IsPositive>
<Total>90</Total>
</Construct>
<Construct>
<ConstructID>65</ConstructID>
<ConstructName>Personal Development</ConstructName> <IsPositive>positive</IsPositive>
<Total>85</Total>
</Construct>
<Construct>
<ConstructID>59</ConstructID>
<ConstructName>Personal Standards</ConstructName>
<IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
<Construct>
<ConstructID>57</ConstructID>
<ConstructName>Risk</ConstructName>
<IsPositive>positive</IsPositive>
<Total>61</Total>
</Construct>
<Construct>
<ConstructID>47</ConstructID>
<ConstructName>Character Qualities</ConstructName>
<IsPositive>positive</IsPositive>
<Total>61</Total>
</Construct>
</SectionConstructs>
</Section>
<Section>
<SectionID>14</SectionID>
<SectionName>Money Values</SectionName>
<IsPositive>positive</IsPositive>
<SectionConstructs>
<Construct>
<ConstructID>58</ConstructID>
<ConstructName>Financial Guarantee</ConstructName>
<IsPositive>positive</IsPositive>
<Total>75</Total>
</Construct>
<Construct>
<ConstructID>54</ConstructID>
<ConstructName>Financial Compensation</ConstructName> <IsPositive>positive</IsPositive>
 <Total>90</Total>
</Construct>
<Construct>
<ConstructID>56</ConstructID>
<ConstructName>Status</ConstructName>
<IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
</SectionConstructs>
</Section>
<Section>
<SectionID>15</SectionID>
<SectionName>People Values</SectionName>
<IsPositive>positive</IsPositive>
<SectionConstructs>
<Construct>
<ConstructID>50</ConstructID>
<ConstructName>Interest in People</ConstructName>
<IsPositive>positive</IsPositive>
<Total>76</Total>
</Construct>
<Construct>
<ConstructID>62</ConstructID>
<ConstructName>Social Interaction</ConstructName>
<IsPositive>positive</IsPositive>
<Total>56</Total>
</Construct>
<Construct>
<ConstructID>68</ConstructID>
<ConstructName>Servanthood</ConstructName>
<IsPositive>positive</IsPositive>
<Total>57</Total>
</Construct>
</SectionConstructs>
</Section>
<Section>
<SectionID>16</SectionID>
<SectionName>Environmental Values</SectionName>
<IsPositive>positive</IsPositive>
<SectionConstructs>
<Construct>
<ConstructID>55</ConstructID>
<ConstructName>Freedom Of Lifestyle</ConstructName>
<IsPositive>positive</IsPositive>
<Total>73</Total>
</Construct>
<Construct>
<ConstructID>64</ConstructID>
<ConstructName>Predictable Environment</ConstructName> <IsPositive>positive</IsPositive>
<Total>64</Total>
</Construct>
<Construct>
<ConstructID>153</ConstructID>
<ConstructName>Repetitiveness</ConstructName>
<IsPositive>positive</IsPositive>
<Total>41</Total>
</Construct>
<Construct>
<ConstructID>60</ConstructID>
<ConstructName>Cultural Prejudice</ConstructName>
<IsPositive>positive</IsPositive>
<Total>49</Total>
</Construct>
</SectionConstructs>
</Section>
<Section>
<SectionID>17</SectionID>
<SectionName>Leadership Values</SectionName>
<IsPositive>positive</IsPositive>
<SectionConstructs>
<Construct>
<ConstructID>69</ConstructID>
<ConstructName>Result Orientation</ConstructName>
<IsPositive>positive</IsPositive>
<Total>72</Total>
</Construct>
<Construct>
<ConstructID>51</ConstructID>
<ConstructName>Autonomy</ConstructName>
<IsPositive>positive</IsPositive>
<Total>92</Total>
</Construct>
<Construct>
<ConstructID>52</ConstructID>
<ConstructName>Authority</ConstructName>
<IsPositive>positive</IsPositive>
<Total>83</Total>
</Construct>
<Construct>
<ConstructID>66</ConstructID>
<ConstructName>Challenging Attributes</ConstructName>
 <IsPositive>positive</IsPositive>
<Total>71</Total>
</Construct>
<Construct>
<ConstructID>67</ConstructID>
<ConstructName>Multi Tasking</ConstructName>
<IsPositive>positive</IsPositive>
<Total>52</Total>
</Construct>
</SectionConstructs>
</Section>
<Section>
<SectionID>18</SectionID>
<SectionName>Physical Values</SectionName>
<IsPositive>positive</IsPositive>
<SectionConstructs>
<Construct>
<ConstructID>70</ConstructID>
<ConstructName>Physical Challenges</ConstructName>
<IsPositive>positive</IsPositive>
<Total>41</Total>
</Construct>
<Construct>
<ConstructID>63</ConstructID>
<ConstructName>Physical Activities</ConstructName>
<IsPositive>positive</IsPositive>
<Total>49</Total>
</Construct>
</SectionConstructs>
</Section>
<Section>
<SectionID>19</SectionID>
<SectionName>Artistic Values</SectionName>
<IsPositive>positive</IsPositive>
<SectionConstructs>
<Construct>
<ConstructID>61</ConstructID>
<ConstructName>Artistic Appreciation</ConstructName>
<IsPositive>positive</IsPositive>
<Total>73</Total>
</Construct>
<Construct>
<ConstructID>53</ConstructID>
<ConstructName>Originality</ConstructName>
<IsPositive>positive</IsPositive>
<Total>97</Total>
</Construct>
</SectionConstructs>
</Section>
<Section>
<SectionID>20</SectionID>
<SectionName>Fields of Interest</SectionName>
<IsPositive>positive</IsPositive>
<SectionConstructs>
<Construct>
<ConstructID>116</ConstructID>
<ConstructName>General Culture</ConstructName>
<IsPositive>positive</IsPositive>
<Total>38</Total>
</Construct>
<Construct>
<ConstructID>117</ConstructID>
<ConstructName>Entrepreneur</ConstructName>
<IsPositive>positive</IsPositive>
<Total>85</Total>
</Construct>
<Construct>
<ConstructID>118</ConstructID>
<ConstructName>Business Interaction</ConstructName>
<IsPositive>positive</IsPositive>
<Total>75</Total>
</Construct>
<Construct>
<ConstructID>119</ConstructID>
<ConstructName>Technology</ConstructName>
<IsPositive>positive</IsPositive>
<Total>99</Total>
</Construct>
<Construct>
<ConstructID>130</ConstructID>
<ConstructName>Marketing</ConstructName>
<IsPositive>positive</IsPositive>
<Total>87</Total>
</Construct>
<Construct>
<ConstructID>115</ConstructID>
<ConstructName>Service</ConstructName>
<IsPositive>positive</IsPositive>
<Total>49</Total>
</Construct>
<Construct>
<ConstructID>131</ConstructID>
<ConstructName>Research</ConstructName>
<IsPositive>positive</IsPositive>
<Total>70</Total>
</Construct>
<Construct>
<ConstructID>129</ConstructID>
<ConstructName>Aeronautics</ConstructName>
<IsPositive>positive</IsPositive>
<Total>45</Total>
</Construct>
<Construct>
<ConstructID>127</ConstructID>
<ConstructName>Administration</ConstructName>
<IsPositive>positive</IsPositive>
<Total>57</Total>
</Construct>
<Construct>
<ConstructID>126</ConstructID>
<ConstructName>Training</ConstructName>
<IsPositive>positive</IsPositive>
<Total>75</Total>
</Construct>
<Construct>
<ConstructID>125</ConstructID>
<ConstructName>Medical</ConstructName>
<IsPositive>positive</IsPositive>
<Total>33</Total>
</Construct>
<Construct>
<ConstructID>124</ConstructID>
<ConstructName>Mechanical</ConstructName>
<IsPositive>positive</IsPositive>
<Total>40</Total>
</Construct>
<Construct>
<ConstructID>123</ConstructID>
<ConstructName>Entertainment</ConstructName>
<IsPositive>positive</IsPositive>
<Total>56</Total>
</Construct>
<Construct>
<ConstructID>122</ConstructID>
<ConstructName>Arts</ConstructName>
<IsPositive>positive</IsPositive>
<Total>83</Total>
</Construct>
<Construct>
<ConstructID>128</ConstructID>
<ConstructName>Human Resources</ConstructName>
<IsPositive>positive</IsPositive>
<Total>68</Total>
</Construct>
<Construct>
<ConstructID>120</ConstructID>
<ConstructName>Science</ConstructName>
<IsPositive>positive</IsPositive>
<Total>66</Total>
</Construct>
<Construct>
<ConstructID>121</ConstructID>
<ConstructName>Outdoors</ConstructName>
<IsPositive>positive</IsPositive>
<Total>45</Total>
</Construct>
</SectionConstructs>
</Section>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
<Section/>
</AssessmentResults>
</AssessmentResult>
EOD;

// MAKE AN OBJECT FROM THE XML
$obj = simpleXML_Load_String($xml);

// ITERATE OVER THE ELEMENTS IN THE OBJECT
foreach ($obj->AssessmentResults->Section as $section)
{
    // SOME OF THESE ARE EMPTY
    if (!empty($section->SectionName))
    {
        echo '<h3>' . $section->SectionName. '</h3>';
        foreach ($section->SectionConstructs->Construct as $construct)
        {
            echo $construct->ConstructName;
            echo ' ';
            echo $construct->Total;
            echo PHP_EOL;
        }
        echo PHP_EOL;
    }
}

Open in new window

HTH, ~Ray
Hi Ray

Thank you very much for your assistance here.
I have used your code but have not been able to get it to work.

I believe it is the <<<EOD that I need to insert into my code but have no idea how and why. I am pasting mu code here but just to let you know I have put an invalid url to the xml file as I dont want this out there in the public domain. If you need the correct one could we deal with it through email or something. mine is paul@iqit.co.nz

Also this is only a small part of a much bigger picture and I might be in slightly over my head. Do you do contract work and if so would you be interested in looking at this job and working with me.

Cheers
Paul

<?php

error_reporting(E_ALL);
echo '<pre>';

$completeurl ="http://www.functionalintelligence.com/index.jsp?pg=-544&login=1&user=Glentapara1&passw=VwPX85&getxml=true&reportId=2052";

$xml = simplexml_load_file($completeurl);

// MAKE AN OBJECT FROM THE XML
$obj = simpleXML_Load_String($xml);

// ITERATE OVER THE ELEMENTS IN THE OBJECT
foreach ($obj->AssessmentResults->Section as $section)
{
    // SOME OF THESE ARE EMPTY
    if (!empty($section->SectionName))
    {
        echo '<h3>' . $section->SectionName. '</h3>';
        foreach ($section->SectionConstructs->Construct as $construct)
        {
            echo $construct->ConstructName;
            echo ' ';
            echo $construct->Total;
            echo PHP_EOL;
        }
        echo PHP_EOL;
    }
}

?>
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer