From: user on
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

-----------------------------------------------------------------------------

<?php
$BillLocation = "/home/cmi/Integration/xml_files";
$StyleSheet = "Bill.xsl";
$DirHandle = opendir($BillLocation);
echo "<table border=\"1\">";
echo "<tr>";
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 "<td>" . "<a href='$FileName'>$BillMonth" . " " .
"$BillYear</a>" . "</td>" . "\n";
echo "</tr>";

}
}
}
echo "</table>";
closedir($DirHandle);

$result = DisplayBill($MemberId, $FileName, $StyleSheet);
From: Michael Shadle on
On Thu, Aug 26, 2010 at 2:54 AM, <user(a)domain.invalid> wrote:
> 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.

a) first, your email address isn't correct

b) second, it looks like you intend on applying a stylesheet to get
your results. if you don't require XSL, you could look at just using
PHP's simplexml and/or XML DOM functions. it looks like you might just
be using the XSL to transform the XML anwyay; so from what it looks
like you -do not- need XSL in the mix.

c) you can put the PHP in any file you want

d) i believe xpath should work without any problems.
From: Michael Shadle on
On Thu, Aug 26, 2010 at 3:10 AM, Sridhar Pandurangiah
<sridharpandu(a)gmail.com> wrote:
> 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?

honestly, that's a little bit too "i'm writing code and solving all
your problems for you" for me... it's hard to concentrate, i have to
actually do the code, not read about it and try to figure it out from
a description :)

feel free to pastebin it, if i don't help you quick maybe someone else will.
From: Sridhar Pandurangiah on
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: mike503(a)gmail.com (Michael Shadle)
To:
Date: Thu Aug 26 2010 15:43:33 GMT+0530 (IST)
From: Sridhar Pandurangiah on
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: mike503(a)gmail.com (Michael Shadle)
To:
Date: Thu Aug 26 2010 15:32:13 GMT+0530 (IST)