Korzystam z przykładu 1 który jest pod tym linkiem:
http://www.w3schools.com/php/func_xml_parse.asp

a więc:
  1. <?php
  2. $parser=xml_parser_create();
  3.  
  4. function char($parser,$data)
  5. {
  6. echo $data;
  7. }
  8.  
  9. xml_set_character_data_handler($parser,"char");
  10. $fp=fopen("test.xml","r");
  11.  
  12. while ($data=fread($fp,4096))
  13. {
  14. xml_parse($parser,$data,feof($fp)) or
  15. die (sprintf("XML Error: %s at line %d",
  16. xml_error_string(xml_get_error_code($parser)),
  17. xml_get_current_line_number($parser)));
  18. }
  19.  
  20. xml_parser_free($parser);
  21. ?>



  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <note>
  3. <to>Tove</to>
  4. <from>Jani</from>
  5. <heading>Reminder</heading>
  6. <body>Don't forget me this weekend!</body>
  7. </note>



i teraz chcę parsować tylko część tego pliku xml powiedzmy 100 znaków, regulacja 2 parametrem fread nic tu nie daje