# Perl/PhP coding assistance



## bpgt64 (Nov 18, 2011)

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.


----------



## W1zzard (Nov 18, 2011)

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?


----------



## bpgt64 (Nov 18, 2011)

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


Spoiler



<?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>


----------



## Disparia (Nov 18, 2011)

One way could be XSL Tranform.


```
<!-- 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.


----------



## bpgt64 (Nov 18, 2011)

How does this take the input of the XML document in?  I am adding some stuff to the top post...


----------



## bpgt64 (Nov 18, 2011)

W1zzard said:


> 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.


----------

