Help me convert xml to php array

Discussion in 'PHP' started by shaikjavedm, Jun 29, 2012.

  1. #1
    Can some help me to convert the below xml data into php array. Thanks in advance.

    <dataroot>
                  <content id= "1">
                                <quest><![CDATA[<FONT FACE="Arial">Which of the following is not the measure of a physical quantity?</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial">kilogram</FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial">impulse</FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial">energy</FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial">density</FONT>]]></opt4>
                                <ans><![CDATA[a]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial">kilogram is the name of the fundamental unit of mass</FONT>]]></ans_desc>
                  </content>
                  <content id= "2">
                                <quest><![CDATA[<FONT FACE="Arial">Which of the following sets can enter into the list of fundamental quantities 
      in any system of units?</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial">length, mass and velocity</FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial">length, time and velocity</FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial">mass, time and velocity</FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial">length, time and mass</FONT>]]></opt4>
                                <ans><![CDATA[d]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial">velocity cannot enter in this set because it itself involves length and time.</FONT>]]></ans_desc>
                  </content>
                  <content id= "3">
                                <quest><![CDATA[<FONT FACE="Arial">If the unit of force and length are doubled, the unit of energy will be</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial">Å’ times</FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial">Å“ times</FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial">2 times</FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial">4 times</FONT>]]></opt4>
                                <ans><![CDATA[d]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P>Energy = Force <img src="Images/Phys1/XLAD670.gif" WIDTH=12 HEIGHT=13 align="absmiddle"> 
      distance = Force <img src="Images/Phys1/XLAD670.gif" WIDTH=12 HEIGHT=13 align="absmiddle"> 
      length.</P>
    <P>When force and length are doubled, the unit of energy will becomes four times 
      that of its initial value.</P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "4">
                                <quest><![CDATA[<FONT FACE="Arial">Given that displacement of a particle is given by <img src="Images/Phys1/XLQ680.gif" WIDTH=101 HEIGHT=21 align="absmiddle"> 
      where t denotes the time. The unit of K is</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial">hertz</FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial">metre</FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial">radian</FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial">second</FONT>]]></opt4>
                                <ans><![CDATA[a]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P>Here K is dimensionless. Thus </P>
    <P><img src="Images/Phys1/XLAD680.gif" WIDTH=198 HEIGHT=41 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "5">
                                <quest><![CDATA[<FONT FACE="Arial">Dimensions of velocity gradient are same as that of </FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial">time period</FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial">frequency</FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial">angular acceleration</FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial">acceleration</FONT>]]></opt4>
                                <ans><![CDATA[b]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P>[velocity gradient ]</P>
    <P>= [ velocity] / [ distance]</P>
    <P><img src="Images/Phys1/XLAD690.gif" WIDTH=128 HEIGHT=24 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "6">
                                <quest><![CDATA[<FONT FACE="Arial">Which of the following physical quantities is/are dimensionless?</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial">length</FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial">time</FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial">mass</FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial">all of these</FONT>]]></opt4>
                                <ans><![CDATA[d]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial">all these quantities are dimensionless.</FONT>]]></ans_desc>
                  </content>
                  <content id= "7">
                                <quest><![CDATA[<FONT FACE="Arial">Erg <img src="Images/Phys1/XLQ710.gif" WIDTH=12 HEIGHT=13 align="absmiddle"> 
      sec is the unit of </FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial">angle</FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial">momentum</FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial">gravitational constant</FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial">Planck's constant</FONT>]]></opt4>
                                <ans><![CDATA[d]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial">The unit of Planck’s constant is <img src="Images/Phys1/XLAD710.gif" WIDTH=57 HEIGHT=17 align="absmiddle"></FONT>]]></ans_desc>
                  </content>
                  <content id= "8">
                                <quest><![CDATA[<FONT FACE="Arial">Which of the following have same dimension?</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial">pressure and density</FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial">gravitational potential and energy</FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial">impulse and momentum</FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial">stress and strain</FONT>]]></opt4>
                                <ans><![CDATA[c]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P>Impulse = force <img src="Images/Phys1/XLAD720.gif" WIDTH=12 HEIGHT=13 align="absmiddle"> 
      time</P>
    <P><img src="Images/Phys1/XLAD721.gif" WIDTH=144 HEIGHT=22 align="absmiddle"></P>
    <P>Momentum = mass <img src="Images/Phys1/XLAD720.gif" WIDTH=12 HEIGHT=13 align="absmiddle"> 
      velocity </P>
    <P><img src="Images/Phys1/XLAD723.gif" WIDTH=69 HEIGHT=22 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD724.gif" WIDTH=64 HEIGHT=21 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "9">
                                <quest><![CDATA[<FONT FACE="Arial">Which of the following pairs of physical quantities will have same dimensional 
      formula</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial">work and couple</FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial">force and power</FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial">latent heat and specific heat</FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial">work and power</FONT>]]></opt4>
                                <ans><![CDATA[a]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P>work = force <img src="Images/Phys1/XLAD730.gif" WIDTH=12 HEIGHT=13 align="absmiddle"> 
      displacement</P>
    <P><img src="Images/Phys1/XLAD731.gif" WIDTH=245 HEIGHT=24 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD732.gif" WIDTH=209 HEIGHT=21 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD733.gif" WIDTH=90 HEIGHT=22 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD734.gif" WIDTH=69 HEIGHT=22 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "10">
                                <quest><![CDATA[<FONT FACE="Arial">Planck’s constant has same dimension as</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial">energy</FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial">force</FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial">linear momentum</FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial">angular momentum</FONT>]]></opt4>
                                <ans><![CDATA[d]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P><img src="Images/Phys1/XLAD740.gif" WIDTH=114 HEIGHT=17 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD741.gif" WIDTH=161 HEIGHT=44 align="absmiddle"></P>
    <P>Angular momentum <img src="Images/Phys1/XLAD742.gif" WIDTH=28 HEIGHT=17 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD743.gif" WIDTH=142 HEIGHT=22 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "11">
                                <quest><![CDATA[<FONT FACE="Arial">The dimension of Planck’s constant is</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLA750.gif" WIDTH=48 HEIGHT=18 align="absmiddle"></FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLB750.gif" WIDTH=49 HEIGHT=17 align="absmiddle"></FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLC750.gif" WIDTH=53 HEIGHT=18 align="absmiddle"></FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLD750.gif" WIDTH=64 HEIGHT=18 align="absmiddle"></FONT>]]></opt4>
                                <ans><![CDATA[a]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P>We know that E=hv</P>
    <P><img src="Images/Phys1/XLAD750.gif" WIDTH=189 HEIGHT=22 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD751.gif" WIDTH=66 HEIGHT=22 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "12">
                                <quest><![CDATA[<FONT FACE="Arial">Dimension of torque is </FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLA760.gif" WIDTH=48 HEIGHT=18 align="absmiddle"></FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLB760.gif" WIDTH=45 HEIGHT=18 align="absmiddle"></FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLC760.gif" WIDTH=50 HEIGHT=18 align="absmiddle"></FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLD760.gif" WIDTH=44 HEIGHT=18 align="absmiddle"></FONT>]]></opt4>
                                <ans><![CDATA[c]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P>Torque = force <img src="Images/Phys1/XLAD760.gif" WIDTH=12 HEIGHT=13 align="absmiddle"> 
      distance</P>
    <P><img src="Images/Phys1/XLAD761.gif" WIDTH=80 HEIGHT=22 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD762.gif" WIDTH=69 HEIGHT=22 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "13">
                                <quest><![CDATA[<FONT FACE="Arial">The dimensions of angular velocity is</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLA770.gif" WIDTH=45 HEIGHT=18 align="absmiddle"></FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLB770.gif" WIDTH=57 HEIGHT=18 align="absmiddle"></FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLC770.gif" WIDTH=57 HEIGHT=18 align="absmiddle"></FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLD770.gif" WIDTH=50 HEIGHT=18 align="absmiddle"></FONT>c]]></opt4>
                                <ans><![CDATA[c]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P><img src="Images/Phys1/XLAD770.gif" WIDTH=168 HEIGHT=36 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD771.gif" WIDTH=86 HEIGHT=38 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD772.gif" WIDTH=124 HEIGHT=22 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "14">
                                <quest><![CDATA[<FONT FACE="Arial">If <img src="Images/Phys1/XLQ780.gif" WIDTH=70 HEIGHT=18 align="absmiddle"> 
      <FONT FACE="Arial">were chosen as fundamental units of force, velocity and time 
      respectively, the dimensions of mass would be represented as </FONT></FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLA780.gif" WIDTH=36 HEIGHT=16 align="absmiddle"></FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLB780.gif" WIDTH=44 HEIGHT=18 align="absmiddle"></FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLC780.gif" WIDTH=45 HEIGHT=18 align="absmiddle"></FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLD780.gif" WIDTH=54 HEIGHT=18 align="absmiddle"></FONT>]]></opt4>
                                <ans><![CDATA[c]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P>We know that Force = mass <img src="Images/Phys1/XLAD780.gif" WIDTH=12 HEIGHT=13 align="absmiddle"> 
      acceleration</P>
    <P><img src="Images/Phys1/XLAD781.gif" WIDTH=266 HEIGHT=38 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD782.gif" WIDTH=100 HEIGHT=38 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "15">
                                <quest><![CDATA[<FONT FACE="Arial">If energy E, velocity V and time T are taken as the fundamental units, what 
      is the dimensional formula for energy per unit area?</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial">E V T</FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLB790.gif" WIDTH=54 HEIGHT=18 align="absmiddle"></FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLC790.gif" WIDTH=57 HEIGHT=18 align="absmiddle"></FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLD790.gif" WIDTH=56 HEIGHT=18 align="absmiddle"></FONT>]]></opt4>
                                <ans><![CDATA[c]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P><img src="Images/Phys1/XLAD790.gif" WIDTH=81 HEIGHT=36 align="absmiddle"> 
      Here a= 1</P>
    <P>Now <img src="Images/Phys1/XLAD791.gif" WIDTH=65 HEIGHT=36 align="absmiddle"></P>
    <P>Or	<img src="Images/Phys1/XLAD792.gif" WIDTH=114 HEIGHT=22 align="absmiddle"></P>
    <P>	<img src="Images/Phys1/XLAD793.gif" WIDTH=68 HEIGHT=22 align="absmiddle"></P>
    <P>This gives <img src="Images/Phys1/XLAD794.gif" WIDTH=133 HEIGHT=17 align="absmiddle"></P>
    <P>So,		c= -2</P>
    <P><img src="Images/Phys1/XLAD795.gif" WIDTH=132 HEIGHT=41 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "16">
                                <quest><![CDATA[<FONT FACE="Arial">If the volocity of light c, universal gravitational constant G and Planck’s 
      constant h be taken as the fundamental units, then the dimentional formula for 
      mass is.</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLA800.gif" WIDTH=54 HEIGHT=25 align="absmiddle"></FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLB800.gif" WIDTH=54 HEIGHT=25 align="absmiddle"></FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLC800.gif" WIDTH=54 HEIGHT=25 align="absmiddle"></FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLD800.gif" WIDTH=44 HEIGHT=22 align="absmiddle"></FONT>]]></opt4>
                                <ans><![CDATA[a]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P>Let <img src="Images/Phys1/XLAD800.gif" WIDTH=74 HEIGHT=20 align="absmiddle"></P>
    <P>	<img src="Images/Phys1/XLAD801.gif" WIDTH=229 HEIGHT=22 align="absmiddle"></P>
    <P>	<img src="Images/Phys1/XLAD802.gif" WIDTH=168 HEIGHT=21 align="absmiddle"></P>
    <P>So,	<img src="Images/Phys1/XLAD803.gif" WIDTH=145 HEIGHT=18 align="absmiddle"></P>
    <P>And 	<img src="Images/Phys1/XLAD804.gif" WIDTH=88 HEIGHT=17 align="absmiddle"></P>
    <P>Solving, we get <img src="Images/Phys1/XLAD805.gif" WIDTH=140 HEIGHT=36 align="absmiddle"></P>
    <P>		<img src="Images/Phys1/XLAD806.gif" WIDTH=110 HEIGHT=26 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "17">
                                <quest><![CDATA[<FONT FACE="Arial">A quantity X multiplied by time gives angular momentum. Then dimensional 
      formula of X is</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLA810.gif" WIDTH=50 HEIGHT=18 align="absmiddle"></FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLB810.gif" WIDTH=29 HEIGHT=18 align="absmiddle"></FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLC810.gif" WIDTH=50 HEIGHT=18 align="absmiddle"></FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLD810.gif" WIDTH=49 HEIGHT=18 align="absmiddle"></FONT>]]></opt4>
                                <ans><![CDATA[a]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P>Angular momentum = m v r</P>
    <P><img src="Images/Phys1/XLAD810.gif" WIDTH=14 HEIGHT=13 align="absmiddle"> 
      dimensions of angular momentum</P>
    <P><img src="Images/Phys1/XLAD811.gif" WIDTH=140 HEIGHT=22 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD812.gif" WIDTH=205 HEIGHT=22 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD813.gif" WIDTH=196 HEIGHT=22 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "18">
                                <quest><![CDATA[<FONT FACE="Arial">What is the dimensional fromula of <img src="Images/Phys1/XLQ820.gif" WIDTH=29 HEIGHT=20 align="absmiddle"> 
      where the letters have their their usual meanings</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLA820.gif" WIDTH=54 HEIGHT=21 align="absmiddle"></FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLB820.gif" WIDTH=54 HEIGHT=21 align="absmiddle"></FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLC820.gif" WIDTH=57 HEIGHT=21 align="absmiddle"></FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLD820.gif" WIDTH=66 HEIGHT=21 align="absmiddle"></FONT>]]></opt4>
                                <ans><![CDATA[c]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P><img src="Images/Phys1/XLAD820.gif" WIDTH=150 HEIGHT=22 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD821.gif" WIDTH=138 HEIGHT=22 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "19">
                                <quest><![CDATA[<FONT FACE="Arial">Given that <img src="Images/Phys1/XLQ830.gif" WIDTH=68 HEIGHT=20 align="absmiddle"> 
      , where F denotes force and t time, then the dimensions of a and b are respectively.</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLA830.gif" WIDTH=101 HEIGHT=22 align="absmiddle"></FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLB830.gif" WIDTH=62 HEIGHT=20 align="absmiddle"></FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLC830.gif" WIDTH=85 HEIGHT=20 align="absmiddle"></FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLD830.gif" WIDTH=129 HEIGHT=20 align="absmiddle"></FONT>]]></opt4>
                                <ans><![CDATA[d]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P><img src="Images/Phys1/XLAD830.gif" WIDTH=74 HEIGHT=20 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD831.gif" WIDTH=198 HEIGHT=41 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD832.gif" WIDTH=178 HEIGHT=42 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
                  <content id= "20">
                                <quest><![CDATA[<FONT FACE="Arial">If K represents kinetic energy, V velocity and T time and these are chosed as the fundamental units then , the 
      unit of surface tension will be</FONT>]]></quest>
                                <opt1><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLA840.gif" WIDTH=56 HEIGHT=18 align="absmiddle"></FONT>]]></opt1>
                                <opt2><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLB840.gif" WIDTH=58 HEIGHT=18 align="absmiddle"></FONT>]]></opt2>
                                <opt3><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLC840.gif" WIDTH=62 HEIGHT=18 align="absmiddle"></FONT>]]></opt3>
                                <opt4><![CDATA[<FONT FACE="Arial"><img src="Images/Phys1/XLD840.gif" WIDTH=58 HEIGHT=18 align="absmiddle"></FONT>]]></opt4>
                                <ans><![CDATA[a]]></ans>
                                <ans_desc><![CDATA[<FONT FACE="Arial"><P><img src="Images/Phys1/XLAD840.gif" WIDTH=157 HEIGHT=22 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD841.gif" WIDTH=312 HEIGHT=44 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD842.gif" WIDTH=160 HEIGHT=44 align="absmiddle"></P>
    <P><img src="Images/Phys1/XLAD843.gif" WIDTH=74 HEIGHT=22 align="absmiddle"></P>
    </FONT>]]></ans_desc>
                  </content>
    </dataroot>
    Code (markup):
     
    shaikjavedm, Jun 29, 2012 IP
  2. Oli3L

    Oli3L Active Member

    Messages:
    207
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    70
    #2
    I'm not sure how well this is.. but it's worth a shot
    
    /*
     *   $t = XML Content
     */
    
    $pattern = "#<content id= \"(?<id>[0-9]+)\">\s*<quest><!\[CDATA\[<FONT FACE=\"Arial\">(?<quest>.*?)<\/FONT>\]\]>\s*<\/quest>\s*<opt1><!\[CDATA\[<FONT FACE=\"Arial\">(?<option1>.*?)<\/FONT>\]\]>";
    $pattern .= "</opt1>\s*<opt2><!\[CDATA\[<FONT FACE=\"Arial\">(?<option2>.*?)<\/FONT>\]\]></opt2>\s*";
    $pattern .= "<opt3><!\[CDATA\[<FONT FACE=\"Arial\">(?<option3>.*?)<\/FONT>\]\]></opt3>\s*<opt4><!\[CDATA\[<FONT FACE=\"Arial\">(?<option4>.*?)<\/FONT>\]\]></opt4>\s*";
    $pattern .= "<ans><!\[CDATA\[(?<ans>[a-z])\]\]><\/ans>\s*";
    $pattern .= "<ans_desc><!\[CDATA\[<FONT FACE=\"Arial\">(?<ans_desc>.*?)<\/FONT>\]\]><\/ans_desc>\s*";
    $pattern .= "<\/content>#is";
    preg_match_all($pattern, $t, $matches);
    unset($matches[0],$matches[1],$matches[2],$matches[3],$matches[4],$matches[5],$matches[6],$matches[7],$matches[8]);
    $questions = array();
    $i = 0;
    foreach($matches as $key => $value) {
        for($x = 0; $x < count($matches["id"]); $x++) {
            $i = 0;
            foreach($value as $id) {
                $questions[$i][$key] = $id;
                $i++;
            }
        }
    
    }
    print_r($questions);
    
    PHP:
     
    Oli3L, Jun 29, 2012 IP
  3. shaikjavedm

    shaikjavedm Member

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    Thank you, I have tried the code but it has given a long error, I have included a few lines from it below:
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: Unit01.xml:23: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xBC 0x20 0x74 0x69 in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: <opt1>¼ times</opt1> in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: Unit01.xml:28: parser error : AttValue: " or ' expected in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: <ans_desc><P>Energy = Force <img src="Images/Phys1/XLAD670.gif" WIDTH= in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: Unit01.xml:28: parser error : attributes construct error in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: <ans_desc><P>Energy = Force <img src="Images/Phys1/XLAD670.gif" WIDTH= in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: Unit01.xml:28: parser error : Couldn't find end of Start Tag img line 28 in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: <ans_desc><P>Energy = Force <img src="Images/Phys1/XLAD670.gif" WIDTH= in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: Unit01.xml:29: parser error : AttValue: " or ' expected in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: distance = Force <img src="Images/Phys1/XLAD670.gif" WIDTH=12 HEIGHT=13 align= in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: Unit01.xml:29: parser error : attributes construct error in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: distance = Force <img src="Images/Phys1/XLAD670.gif" WIDTH=12 HEIGHT=13 align= in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: Unit01.xml:29: parser error : Couldn't find end of Start Tag img line 29 in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: distance = Force <img src="Images/Phys1/XLAD670.gif" WIDTH=12 HEIGHT=13 align= in C:\wamp\www\quiz\questions.php on line 5
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in C:\wamp\www\quiz\questions.php on line 5
    Code (markup):
     
    shaikjavedm, Jun 29, 2012 IP