[PHP] XML with PHP
Hi I am trying to read XML files (invoices) from a directory and display them to the visitor. Each XML file contains several invoices. The visitor then clicks on the XML file (invoices). My PHP snippet should open the xml file and locate the appropriate invoice and display the content. I have managed to list the directory contents using the following PHP snippet. The function call below DisplayBill($MemberId, $FileName, $StyleSheet) should take the memberid (login), the xml file name which has been clicked and the stylesheet to be used. I now have the following doubts for which I need clarifications Architecturally is it necessary the DisplayBill should be a seperate php file or can it exist as a function in the same file as the code below? Should the Invoices be displayed as a web form for me to capture the user click to retrieve the appropriate file and invoice so that I can display it to the user. I intend to parse the XML file using XPath (at this stage I am not sure if php supports Xpath and XQuery!) Any help would be appreciated Best regards Sridhar - "; echo ""; While (($FileName = readdir($DirHandle)) !== false) { if ($FileName != "." && $FileName != "..") { if (strpos($FileName, "xml") !== false) { $BillYear = substr($FileName, 0, 4); $BillMonth = substr($FileName, 5, 2); switch ($BillMonth) { case "01": $BillMonth = "January"; break; case "02": $BillMonth = "February"; break; case "03": $BillMonth = "March"; break; case "04": $BillMonth = "April"; break; case "05": $BillMonth = "May"; break; case "06": $BillMonth = "June"; break; case "07": $BillMonth = "July"; break; case "08": $BillMonth = "August"; break; case "09": $BillMonth = "September"; break; case "10": $BillMonth = "October"; break; case "11": $BillMonth = "November"; break; case "12": $BillMonth = "December"; break; } echo "" . "$BillMonth" . " " . "$BillYear" . "" . "\n"; echo ""; } } } echo ""; closedir($DirHandle); $result = DisplayBill($MemberId, $FileName, $StyleSheet); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML with PHP
Hi I guess my post was misunderstood. I was just trying to figure out if there is a better way other than displaying a form. That's the reason I posted my php snippet in my first post. Thanks for the help. Best regards Sridhar Original Message Subject: Re: [PHP] XML with PHP From: mike...@gmail.com (Michael Shadle) To: Date: Thu Aug 26 2010 15:43:33 GMT+0530 (IST) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML with PHP
Mike Thanks a ton for the quick response. I have updated the mail id on my email client (using Mozilla TB) and I did repost but your reply was quicker! Will try this out and post the results on this thread. Just waiting for someone to throw light on how to capture the "filename" that the user clicked. Should I display the directory listing as a form? Best regards Sridhar Original Message Subject: Re: [PHP] XML with PHP From: mike...@gmail.com (Michael Shadle) To: Date: Thu Aug 26 2010 15:32:13 GMT+0530 (IST) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Error in initialising XML parser
Hi I am writing a PHP snippet to display invoices that is generated by another computer application. The use case is as follows 1. The other computer application generates the invoices for the month in XML and puts it in a common dirctory. So at anytime there could be multiple files. Each file contains several invoices. These invoices are for different vendors. 2. My PHP snippet will list all the files in the directory. I have got this part right after a lot of research, phew! It displays only xml files and keeps out the others like files begining with "." (dot) etc. This is listed as a series of checkboxes so that the user can view the list of invoices available. Once the user clicks on the checkboxes I POST the file name to the server with the following code $BillLocation = "/home/cmi/Integration/xml_files"; $StyleSheet = "Bill.xsl"; $DirHandle = opendir($BillLocation); if ($_POST['_submit_check']) { $MyBill = new Displaybill($_POST[BillChosen]); $MyBill->parse($_POST[BillChosen]); $MyBill->Show_Bill($MemberId, $StyleSheet); } { $result = List_Directory($DirHandle); } I get a following error Fatal error: Class 'Displaybill' not found in /home/sridhar/Sastra/2010-ClubMan-Integration/ListAvailableBills.php on line 15 I have the "Displaybill" class in the same location as the other file still PHP is not able to locate it. What could be wrong? Any help would be appreciated. Running the whole thing on localhost with the vhosts configured to teh above directory. Best regards Sridhar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Error in initialising XML parser
Thanks, PHP is now able to include the class file Best regards Original Message Subject: Re: [PHP] Error in initialising XML parser From: a...@ashleysheridan.co.uk (a...@ashleysheridan.co.uk) To: Date: Mon Sep 06 2010 13:56:39 GMT+0530 (IST) PHO won't automatically include a class file by default. You either need to manually include it with a require, include it or require_once line, or use an automagical include script. As it stands, you're getting the error because php doesn't know where your class is. Thanks, Ash http://www.ashleysheridan.co.uk - Reply message - From: "Sridhar Pandurangiah" Date: Mon, Sep 6, 2010 09:12 Subject: [PHP] Error in initialising XML parser To: Hi I am writing a PHP snippet to display invoices that is generated by another computer application. The use case is as follows 1. The other computer application generates the invoices for the month in XML and puts it in a common dirctory. So at anytime there could be multiple files. Each file contains several invoices. These invoices are for different vendors. 2. My PHP snippet will list all the files in the directory. I have got this part right after a lot of research, phew! It displays only xml files and keeps out the others like files begining with "." (dot) etc. This is listed as a series of checkboxes so that the user can view the list of invoices available. Once the user clicks on the checkboxes I POST the file name to the server with the following code $BillLocation = "/home/cmi/Integration/xml_files"; $StyleSheet = "Bill.xsl"; $DirHandle = opendir($BillLocation); if ($_POST['_submit_check']) { $MyBill = new Displaybill($_POST[BillChosen]); $MyBill->parse($_POST[BillChosen]); $MyBill->Show_Bill($MemberId, $StyleSheet); } { $result = List_Directory($DirHandle); } I get a following error Fatal error: Class 'Displaybill' not found in /home/sridhar/Sastra/2010-ClubMan-Integration/ListAvailableBills.php on line 15 I have the "Displaybill" class in the same location as the other file still PHP is not able to locate it. What could be wrong? Any help would be appreciated. Running the whole thing on localhost with the vhosts configured to teh above directory. Best regards Sridhar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: workflow system design
Hi Try BPEL. You can look at Intalio which supports BPEL and has a community edition. You can download and try out a few examples. I guess the big players like IBM, Oracle etc should have some BPEL based tools. Best regards Sridhar Original Message Subject: workflow system design From: dany...@gmail.com (gato chlr) To: Date: Tue Sep 07 2010 01:17:01 GMT+0530 (IST) Hi, i know it is not the right place, but, does anybody know a workflow system development process? or methodology? thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Counting Children!
Hi I have an XML generated by another computer application. The format is as below. (Don't worry about the data in the XML. Its the test data). I am able to locate the correct member bill using XPATH. However I have hit a bottleneck. I am unable to echo all the elements. This is what happens $row = simplexml_load_string($member->asXML()); echo $line->particular1; echo $line->amount1; echo $line->particular2; echo $line->amount2; Echoes the first element of the member bill. If I add the same set of statements it echoes the second element and so on. But then if I put the following code which I feel is correct $row = simplexml_load_string($member->asXML()); foreach ($row->line as $line); { echo $line->particular1; echo $line->amount1; echo $line->particular2; echo $line->amount2; } Echoes only the last element of the member. Can someone tell me what's wrong -The XML file - The Great Eastern Club Anna Road Madras BILL A0099 Bill no. : A0099/APRIL 10 Raman C V Run date : 03/05/2010 NO 33,MUGAPPAIR ROAD, PADI, CHENNAI 600032 9840012345 STATEMENT OF ACCOUNTS AND BILL FOR THE MONTH OF APRIL-2010 Particulars Debit Receivables Credit Opening Balance 275.14 - 0.00 CHARGES 33.09 MINIMUM USAGE 220.60 SUBSCRIPTION CHARGES 220.60 WATER CHARGE 22.06 Total Debit 771.49 Total Credit 0.00 Amount to be Received 771.49 Hereafter no reminders will be sent for payment of monthly/Arrears bills. A0100 Bill no. : A0100/APRIL 10 Sandeep Run date : 03/05/2010 NO 12, TNAGAR, CHENNAI 600017 9840012365 STATEMENT OF ACCOUNTS AND BILL FOR THE MONTH OF APRIL-2010 Particulars Debit Receivables Credit Opening Balance 496.38 - 0.00 ENTERTAINMENT CHARGES 33.09 17/06/2010 CASH PCR/000544/10-11 124.00 MINIMUM USAGE 124.00 SUBSCRIPTION CHARGES 220.60 WATER CHARGE 22.06 Total Debit 896.13 Total Credit 124.00 Amount to be Received 772.13 Hereafter no reminders will be sent for payment of monthly/Arrears bills. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Counting Children!
I managed to solve this myself. Here is the code. For some reason "foreach" works for the first set of non unique tags and doesn't work if the non unique tags are nested within the first set. Use the following code to access the tag values of the nested non unique tags. (see the XML file below if this seems confusing) $chi = count($member->line); for ($i = 0; $i < $chi; $i++) { echo $member->line[$i]->particular1; echo $member->line[$i]->amount1; echo $member->line[$i]->particular2; echo $member->line[$i]->amount2; } Best regards Sridhar Sridhar Pandurangiah wrote: Hi I have an XML generated by another computer application. The format is as below. (Don't worry about the data in the XML. Its the test data). I am able to locate the correct member bill using XPATH. However I have hit a bottleneck. I am unable to echo all the elements. This is what happens $row = simplexml_load_string($member->asXML()); echo $line->particular1; echo $line->amount1; echo $line->particular2; echo $line->amount2; Echoes the first element of the member bill. If I add the same set of statements it echoes the second element and so on. But then if I put the following code which I feel is correct $row = simplexml_load_string($member->asXML()); foreach ($row->line as $line); { echo $line->particular1; echo $line->amount1; echo $line->particular2; echo $line->amount2; } Echoes only the last element of the member. Can someone tell me what's wrong -The XML file - The Great Eastern Club Anna Road Madras BILL A0099 Bill no. : A0099/APRIL 10 Raman C V Run date : 03/05/2010 NO 33,MUGAPPAIR ROAD, PADI, CHENNAI 600032 9840012345 STATEMENT OF ACCOUNTS AND BILL FOR THE MONTH OF APRIL-2010 Particulars Debit Receivables Credit Opening Balance 275.14 - 0.00 CHARGES 33.09 MINIMUM USAGE 220.60 SUBSCRIPTION CHARGES 220.60 WATER CHARGE 22.06 Total Debit 771.49 Total Credit 0.00 Amount to be Received 771.49 Hereafter no reminders will be sent for payment of monthly/Arrears bills. A0100 Bill no. : A0100/APRIL 10 Sandeep Run date : 03/05/2010 NO 12, TNAGAR, CHENNAI 600017 9840012365 STATEMENT OF ACCOUNTS AND BILL FOR THE MONTH OF APRIL-2010 Particulars Debit Receivables Credit Opening Balance 496.38 - 0.00 ENTERTAINMENT CHARGES 33.09 17/06/2010 CASH PCR/000544/10-11 124.00 MINIMUM USAGE 124.00 SUBSCRIPTION CHARGES 220.60 WATER CHARGE 22.06 Total Debit 896.13 Total Credit 124.00 Amount to be Received 772.13 Hereafter no reminders will be sent for payment of monthly/Arrears bills. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Xpath arguments in variable
Hi I have the following statement that locates the node "membernumber" with the value A192. This works perfectly fine. $v = $row->xpath('//membernumber[. = "A192"]'); But now I need to pass this value to XPath within a string variable say $v = $row->xpath('//membernumber[. = $MemberId]'); But this doesnt work due to the quotes. What I intend PHP to do is to substitute the value for $MemberId and then execute the XPath query. I have grappled with it for a few days before posting this. Any ideas are most welcome Best regards Sridhar -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Xpath arguments in variable
Original Message Subject: Re: Xpath arguments in variable From: php-gene...@garydjones.name (Gary) To: Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST) Whats wrong with $v = $row->xpath('//membernumber[. = ' . $MemberId . ']'); ? Am I not understanding what you are trying to ask? I tried this but doesn't work. I guess the above statement is concatenating the entire string and the substitution isn't happening What I am trying to do is as follows $MemberId = 'A192'; $v = $row->xpath('//membernumber[. = ' . $MemberId . ']'); The $MemberId should be substituted with A192 and then the xpath query should be executed. The result should be that I locate the membernumber XML element that has the value A912. Best regards Sridhar Sridhar Pandurangiah wrote: now I need to pass this value to XPath within a string variable say $v = $row->xpath('//membernumber[. = $MemberId]'); But this doesnt work due to the quotes. What I intend PHP to do is to substitute the value for $MemberId and then execute the XPath query. I have grappled with it for a few days before posting this. Whats wrong with $v = $row->xpath('//membernumber[. = ' . $MemberId . ']'); ? Am I not understanding what you are trying to ask? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Xpath arguments in variable
Managed to resolve it. Phew! $v = $row->xpath('//membernumber[. = ' . '"' . $MemberId . '"' . ']'); works. Best regards Sridhar Original Message Subject: Re: [PHP] Re: Xpath arguments in variable From: a...@ashleysheridan.co.uk (Ashley Sheridan) To: Date: Wed Sep 15 2010 14:04:33 GMT+0530 (IST) On Wed, 2010-09-15 at 14:03 +0530, Sridhar Pandurangiah wrote: Original Message Subject: Re: Xpath arguments in variable From: php-gene...@garydjones.name (Gary) To: Date: Wed Sep 15 2010 13:34:11 GMT+0530 (IST) Whats wrong with $v = $row->xpath('//membernumber[. = ' . $MemberId . ']'); ? Am I not understanding what you are trying to ask? I tried this but doesn't work. I guess the above statement is concatenating the entire string and the substitution isn't happening What I am trying to do is as follows $MemberId = 'A192'; $v = $row->xpath('//membernumber[. = ' . $MemberId . ']'); The $MemberId should be substituted with A192 and then the xpath query should be executed. The result should be that I locate the membernumber XML element that has the value A912. Best regards Sridhar Sridhar Pandurangiah wrote: now I need to pass this value to XPath within a string variable say $v = $row->xpath('//membernumber[. = $MemberId]'); But this doesnt work due to the quotes. What I intend PHP to do is to substitute the value for $MemberId and then execute the XPath query. I have grappled with it for a few days before posting this. Whats wrong with $v = $row->xpath('//membernumber[. = ' . $MemberId . ']'); ? Am I not understanding what you are trying to ask? Did you try using double quotes? Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php