• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Perl/PhP coding assistance

Joined
Oct 5, 2008
Messages
1,803 (0.30/day)
Location
ATL, GA
System Name My Rig
Processor AMD 3950X
Motherboard X570 TUFF GAMING PLUS
Cooling EKWB Custom Loop, Lian Li 011 G1 distroplate/DDC 3.1 combo
Memory 4x16GB Corsair DDR4-3466
Video Card(s) MSI Seahawk 2080 Ti EKWB block
Storage 2TB Auros NVMe Drive
Display(s) Asus P27UQ
Case Lian Li 011-Dynamic XL
Audio Device(s) JBL 30X
Power Supply Seasonic Titanium 1000W
Mouse Razer Lancehead
Keyboard Razer Widow Maker Keyboard
Software Window's 10 Pro
So, I have been tasked with creating a Perl Script, that parses an XML document for the 5 fields of information repeated in the document in the same order. Returning those 5 items, as Columns 1, Columns 2, Columns 3, 4 and 5 of a Table. I haven't the slightest idea on how to code or where to start. Any thoughts or suggestions? Should I be working with a different scripting language than Perl? or...?

The PhP end of this, is that I need to integrate the Perl script into a website, that allows a user to browse to the xml document of there own, and returns the Table described above to the Web Page.

I have a copy of Frozen Synapse, and Sanctum on Steam for anyone who can help me get this up and running. I have hosting capability and ftp access I can give to my personal Ubuntu web server to trying to set it up.
 
Last edited:
dont use perl, use php. you can run php from the linux command line too if you need to

paste some of your xml. do you need to write your data into a database table ? or what kind of table are you talking about?
 
We need it to return the following fields in a single line in an excell formatted(.csv/xls) table, then know to reset and collect the next 6 variable in line 2 of the table;

basic set-info name
server name
user-name
schedule
generations
retention name

Sample XML below
<?xml version="1.0" encoding="UTF-16"?>
<!DOCTYPE client-config SYSTEM "asigra_conf.dtd">
<client-config version="1.2">
<schedules>
<schedule name="Test " administrative="no" suspended="no" run-at-once="4" replace-existing="yes">
<schedule-details>
<run-schedule>
<schedule-weekly every="1">
<week-day day="Mon"/>
<week-day day="Tue"/>
<week-day day="Wed"/>
<week-day day="Thu"/>
</schedule-weekly>
<schedule-frequency>
<schedule-start when="18:00"/>
<schedule-end when="07:45" after-days="1"/>
</schedule-frequency>
<schedule-period>
<schedule-start-date date="2011-11-17"/>
</schedule-period>
<schedule-tasks run-backup="yes" run-retention="no"/>
</run-schedule>
<run-schedule>
<schedule-weekly every="1">
<week-day day="Fri"/>
</schedule-weekly>
<schedule-frequency>
<schedule-start when="18:00"/>
</schedule-frequency>
<schedule-period>
<schedule-start-date date="2011-11-17"/>
</schedule-period>
<schedule-tasks run-backup="yes" run-retention="no"/>
</run-schedule>
</schedule-details>
</schedule>
<schedule name="Weekly" administrative="no" suspended="no" run-at-once="4" replace-existing="yes">
<schedule-details>
<run-schedule>
<schedule-weekly every="1">
<week-day day="Mon"/>
<week-day day="Tue"/>
<week-day day="Wed"/>
<week-day day="Thu"/>
<week-day day="Fri"/>
</schedule-weekly>
<schedule-frequency>
<schedule-start when="23:00"/>
<schedule-end when="07:00" after-days="1"/>
</schedule-frequency>
<schedule-period>
<schedule-start-date date="1997-01-01"/>
</schedule-period>
<schedule-tasks run-backup="yes" run-retention="no"/>
</run-schedule>
</schedule-details>
</schedule>
</schedules>
<retentions>
<retention-rule name="30 Day Delete Rule" replace-existing="yes">
<delete-options>
<delete-removed unit="30" unit-type="days" generations="0"/>
</delete-options>
</retention-rule>
</retentions>
<backup-sets>
<create-backup-sets>
<new-file-system-backup-set>
<basic-set-info name="Backup of files on C:" owner="BenP" owner-from="." type="regular" replace-existing="yes"/>
<source-server>
<server-name>%ComputerName%</server-name>
<net-provider>DS-Client Computer</net-provider>
</source-server>
<connect-as>
<user-from>.</user-from>
<user-name>BenP</user-name>
<password ispwdhashed="yes">aes-128-cbc$57D94233D2924D438FD70A365D4E613A0B1159BD4DFAF68A351644E67AD5DAF85ACEB7F8C5EE3F0D6886B0254EFC5442</password>
</connect-as>
<file-system-items>
<file-system-item share-name="C:" path="\*.*" include-sub-dirs="yes" generations="30">
<file-system-item-backup-option option="permissions"/>
<file-system-item-backup-option option="alternate-streams"/>
</file-system-item>
</file-system-items>
<generic-backup-options
schedule-name="Test "
detailed-log="yes"
local-storage="no"
local-cache="no"
sla-priority="medium"
stop-on-errors="0"
compression-type="lzop"
blm-infinite-gen="no"
retention-name="30 Day Delete Rule"/>
<file-system-backup-options
no-common-files="no"
use-buffer="no"
open-files="try-deny-write"
open-files-retry="0"
open-files-retry-sec="0"
backup-data-in-remote-storage="no"
follow-junction-point="no"
backup-single-instance-store-file-data="no"
backup-through-vss="yes"
vss-not-involve-writes="no"/>
</new-file-system-backup-set>
<new-file-system-backup-set>
<basic-set-info name="Clone Backup of files on C:" owner="BenP" owner-from="." type="regular" replace-existing="yes"/>
<source-server>
<server-name>%ComputerName%</server-name>
<net-provider>DS-Client Computer</net-provider>
</source-server>
<connect-as>
<user-from>.</user-from>
<user-name>BenP</user-name>
<password ispwdhashed="yes">aes-128-cbc$24F8AD4717966F8B2FBFDBA15F0C20DEF422A912F07EA1BD0FB55317C824AB9EF06AB0DAA5CDEEC224A25BB56AF381F8</password>
</connect-as>
<file-system-items>
<file-system-item share-name="C:" path="\*.*" include-sub-dirs="yes" generations="30">
<file-system-item-backup-option option="permissions"/>
<file-system-item-backup-option option="alternate-streams"/>
</file-system-item>
</file-system-items>
<generic-backup-options
schedule-name=""
detailed-log="yes"
local-storage="no"
local-cache="no"
sla-priority="medium"
stop-on-errors="0"
compression-type="lzop"
blm-infinite-gen="no"
retention-name=""/>
<file-system-backup-options
no-common-files="no"
use-buffer="no"
open-files="try-deny-write"
open-files-retry="0"
open-files-retry-sec="0"
backup-data-in-remote-storage="no"
follow-junction-point="no"
backup-single-instance-store-file-data="no"
backup-through-vss="yes"
vss-not-involve-writes="no"/>
</new-file-system-backup-set>
<new-file-system-backup-set>
<basic-set-info name="Clone Clone Backup of files on C:" owner="BenP" owner-from="." type="regular" replace-existing="yes"/>
<source-server>
<server-name>%ComputerName%</server-name>
<net-provider>DS-Client Computer</net-provider>
</source-server>
<connect-as>
<user-from>.</user-from>
<user-name>BenP</user-name>
<password ispwdhashed="yes">aes-128-cbc$A9B40EF7CC312B2D76C70A5302204D3704AEA1800013DE8A2CFCEAEB05FED351BF22F83CDDE1988758B31BEB79A50219</password>
</connect-as>
<file-system-items>
<file-system-item share-name="C:" path="\*.*" include-sub-dirs="yes" generations="30">
<file-system-item-backup-option option="permissions"/>
<file-system-item-backup-option option="alternate-streams"/>
</file-system-item>
</file-system-items>
<generic-backup-options
schedule-name="Test "
detailed-log="yes"
local-storage="no"
local-cache="no"
sla-priority="medium"
stop-on-errors="0"
compression-type="lzop"
blm-infinite-gen="no"
retention-name="30 Day Delete Rule"/>
<file-system-backup-options
no-common-files="no"
use-buffer="no"
open-files="try-deny-write"
open-files-retry="0"
open-files-retry-sec="0"
backup-data-in-remote-storage="no"
follow-junction-point="no"
backup-single-instance-store-file-data="no"
backup-through-vss="yes"
vss-not-involve-writes="no"/>
</new-file-system-backup-set>
</create-backup-sets>
</backup-sets>
</client-config>
 
One way could be XSL Tranform.

HTML:
<!-- Only a code snippet, won't run on it's own -->
<table class="bsi">
<xsl:for-each select="basic-set-info">
	<tr>
		<td><xsl:value-of select="@name"/></td>
	</tr>
</xsl:for-each>
</table>

Can grab the values and form the structure with an XSL template, applying styles as well.

But it's just as easy with PHP as well, and bit more flexible in using those values too (export a csv, excel, import to database, etc). I can post something up later.
 
How does this take the input of the XML document in? I am adding some stuff to the top post...
 
dont use perl, use php. you can run php from the linux command line too if you need to

paste some of your xml. do you need to write your data into a database table ? or what kind of table are you talking about?

I need it printed back out on the website in the form of a formatted Table. I also need customers to be able to go to this site, and browse to there xml document. Once they select it, the php outputs the info in a table, so they can view/print it.
 
Back
Top