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

  • Home
  • SEARCH
  • 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 6638507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:26:38+00:00 2026-05-25T23:26:38+00:00

So basically what I have been doing is convert one xml file to a

  • 0

So basically what I have been doing is convert one xml file to a well-formed pdf with wamp.
The codes below are simple illustration of my idea.I learnt from the process of parsing xml to html and I suppose that the thing is all about telling xml parser the ways you would like to display on the screen.So then I did it like below:

<?php 
 require('fpdf.php');

 class PDF extends FPDF
 {
   //...I skipped couple of functions like Footer()

   //Display stuff from string in pdf manner
   function Stuff($data)
   {
       $this->SetFont('Arial','',12);
       $this->Cell(0,4,"$data",0,1,'L',true);
       $this->Ln(1);
   }
 }

 //Parse xml start tags
 function start($parser,$element_name,$element_data)
 {
      ......
 }    

 //Parse xml end tags
 function stop($parser,$element_name)
 {
      ......
 }

 //Parse xml contents between start tags and end tags
 function data($parser,$data)
 {
      $pdf->Stuff($data);
 }

 //create pdf page
 $pdf = new PDF();
 $pdf->AliasNbPages();
 $pdf->AddPage();
 $pdf->SetFont('Times','',12);

 //Parse xml file to pdf
 $parser=xml_parser_create();
 xml_set_element_handler($parser,"start","stop");
 xml_set_character_data_handler($parser,"char");
 $fp=fopen("test.xml","r");

 while($data=fread($fp,4096))
 {
     xml_parse($parser,$data,feof($fp)) or 
     die (sprintf("XML Error:$s at line $d",
     xml_error_string(xml_get_error_code($parser)),
     xml_get_current_line_number($parser)));
 }

 xml_parser_free($parser);

?>

Unfortunately I received this warning as I described in the title.However,I tested my xml parser functions with my start,stop and data functions individually,they all worked fine.Then I tried to convert xml to html,everything is still good.It is primarily converting to pdf that I encounter this situation when working on my idea.
Could anyone give me some hints about this problem?

  • 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-05-25T23:26:38+00:00Added an answer on May 25, 2026 at 11:26 pm

    In your data function, you reference $pdf->Stuff() but there is no variable $pdf so that is why you see the error. Because $pdf is not an object because it doesn’t exist. Did you mean $parser->Stuff($data)? or if that function is inside of your class, then maybe it should be $this->Stuff($data)

    You can have the handlers in your class, you just need to specify them a bit differently. You can do

    xml_set_object ( $parser, $this );
    xml_set_element_handler ( $parser, 'start', 'stop' );
    xml_set_character_data_handler ( $parser, 'char' );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have been doing some PHP and Python/Apache/MySQL (WAMP!) development for a while
I have been using LINQ with compiled queries, basically passing into the compiled query
I have been playing with the Ruby library shoes. Basically you can write a
I basically have a page which shows a processing screen which has been flushed
Basically, I have been using both Integer.Parse and CInt in most of my daily
I've been battling to get this right...basically I have the following HTML setup: <div
I basically have the following flow: XML -> JSON -> Spring MVC -> jsp
I basically have a unix process running and it is doing some heavy processing
I have been doing a lot of searching and still can't seem to figure
I have been doing a lot if research into this, but I havent found

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.