Need Help!!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • th1982
    New Member
    • Feb 2008
    • 51

    Need Help!!!!

    I,ve got this xml file :

    <?xml version="1.0" ?>
    - <VNINDEX>
    - <INDEX>
    <SESSION>1724 </SESSION>
    <VNINDEX_DATE>1 5/02/2008</VNINDEX_DATE>
    <TOTALTRADE>0 </TOTALTRADE>
    <VN_INDEX>823.4 6</VN_INDEX>
    <CHANGE>0</CHANGE>
    <CHANGED>0</CHANGED>
    <VOL>0.0</VOL>
    <VAL>0.0</VAL>
    </INDEX>
    - <INDEX>
    <SESSION>1724 </SESSION>
    <VNINDEX_DATE>1 5/02/2008</VNINDEX_DATE>
    <TOTALTRADE>201 7</TOTALTRADE>
    <VN_INDEX>821.0 3</VN_INDEX>
    <CHANGE>-2.43</CHANGE>
    <CHANGED>-0.3</CHANGED>
    <VOL>1121860. 0</VOL>
    <VAL>8.0587E1 0</VAL>
    </INDEX>
    - <INDEX>
    <SESSION>1724 </SESSION>
    <VNINDEX_DATE>1 5/02/2008</VNINDEX_DATE>
    <TOTALTRADE>679 6</TOTALTRADE>
    <VN_INDEX>815.3 1</VN_INDEX>
    <CHANGE>-8.15</CHANGE>
    <CHANGED>-0.99</CHANGED>
    <VOL>4209960. 0</VOL>
    <VAL>3.24737E11 </VAL>
    </INDEX>
    - <INDEX>
    <SESSION>1724 </SESSION>
    <VNINDEX_DATE>1 5/02/2008</VNINDEX_DATE>
    <TOTALTRADE>959 6</TOTALTRADE>
    <VN_INDEX>816.0 3</VN_INDEX>
    <CHANGE>-7.43</CHANGE>
    <CHANGED>-0.9</CHANGED>
    <VOL>5815210. 0</VOL>
    <VAL>4.44194E11 </VAL>
    </INDEX>
    - <INDEX>
    <SESSION>1724 </SESSION>
    <VNINDEX_DATE>1 5/02/2008</VNINDEX_DATE>
    <TOTALTRADE>959 7</TOTALTRADE>
    <VN_INDEX>816.0 3</VN_INDEX>
    <CHANGE>-7.43</CHANGE>
    <CHANGED>-0.9</CHANGED>
    <VOL>5835450. 0</VOL>
    <VAL>4.45024E11 </VAL>
    </INDEX>
    </VNINDEX>

    Now I want to get the data in last INDEX node(in Bold).How can I do it with php?
    Thanks
  • delirio
    New Member
    • Feb 2008
    • 2

    #2
    if you're using xpath would be

    /VNINDEX/INDEX[not(following-sibling::INDEX)]

    or

    /VNINDEX/INDEX[position() = last()]

    Miguel de Melo
    =============== =====
    XSLT by Example

    Comment

    • th1982
      New Member
      • Feb 2008
      • 51

      #3
      Thanks for yr help!!
      but I've got this error when I run it:"Fatal error: Call to undefined function SelectNodes() in C:\wamp\www\VFM website\VFM_tes t\vnindex.php on line 26"
      This is my Code :
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
      <html xmlns="http://www.w3.org/1999/xhtml">
      <link xmlns:xlink="ht tp://www.w3.org/2000/xlink" xlink:type="sim ple" xlink:href="htt p://purpleasia.com/clients/xml/vnindexTableDt. xml#xpointer(//VNINDEX/INDEX[2])">
      </link>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <title>storeXML </title>
      </head>
      <body>
      <?php

      $con = mysql_connect(" localhost","roo t","iloveyou ");
      if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }

      mysql_select_db ('purpasia_vfm' , $con);

      $conn = ftp_connect("pu rpleasia.com") or die("Could not connect");
      ftp_login($conn ,"vfm@purpleasi a.com","vietfun ");
      $url='http://purpleasia.com/clients/xml/bagiaTableDt.xm l';
      $xml=file_get_c ontents($url);
      $VNINDEX = new SimpleXMLElemen t('http://purpleasia.com/clients/xml/vnindexTableDt. xml', null, true);
      xmldom.SelectNo des("/VNINDEX/INDEX[position() = last()]");

      foreach($VNINDE X as $INDEX)
      {
      //$VNINDEX -> $INDEX;

      //$total=$INDEX->TOTALTRADE;
      //$t=max($total)
      //if($t)
      //{
      $date=$INDEX->VNINDEX_DATE ;
      $session=$INDEX->SESSION;
      $vnindex=$INDEX->VN_INDEX;
      $vol=$INDEX->VOL;
      mysql_query("IN SERT INTO vnindex VALUES ('$date','$sess ion','$vnindex' ,'$vol')");
      }
      //}


      mysql_close($co n);

      ftp_close($conn );
      echo "<H1><cente r> Update's Completed</center></H1>";
      ?>
      </body>
      </html>
      Pls help me again.I m newbie in this.Thank very much

      Comment

      • jkmyoung
        Recognized Expert Top Contributor
        • Mar 2006
        • 2057

        #4
        The PHP function would probably be xpath_eval

        http://ca3.php.net/manual/en/function.xpath-eval.php

        Comment

        • th1982
          New Member
          • Feb 2008
          • 51

          #5
          Pls give me the detail of it.With my code like that, how can I put xpath in ?
          Really thanks to your help of all

          Comment

          Working...