Home : General : Perl Programming :

General: Perl Programming: XML and perl: Edit Log

Here is the list of edits for this post
XML and perl
Hi all,

A little help please

I have .cs file in XML

See below.

How do I get this to work in perl.
As I am a not familiar with XML I need to either change this file to perl or get it to run on Apache server in order to extract the data from the client Mysql database.

Any help appreciated

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace SupplierPubUsageExample
class Program
static private string sUsername = "username";
static string sPassword = "password";
static int iLastRefNum = 0;
//static string wsUrl = "http://localhost:3906/domain/SupplierPub.asmx";
static string wsUrl = "http://www.domain.co.uk/1stChoiceServices/SupplierPub.asmx";

static void Main(string[] args)
//GetOrders(sUsername, sPassword, iLastRefNum);
MakeQuote(sUsername, sPassword);

static void GetOrders(string Username, string Password, int LastRefNum)
string ReturnString = "";
wsSupplier.SupplierPub ws = new wsSupplier.SupplierPub();
ws.Url = wsUrl;

ReturnString = ws.GetOrders(Username, Password, LastRefNum);
List<OrderDetails> lOrders = ParseGetOrdersResult(ReturnString);

private class PartDetails
public string pid;
public string pdsc;
public string pcmt;

public PartDetails(string pid, string pdsc, string pcmt)
this.pid = pid;
this.pdsc = pdsc;
this.pcmt = pcmt;

private class OrderDetails
public string rfno;
public string date;
public string cdes;
public string cmak;
public string cran;
public string cyer;
public string cbdy;
public string cbdt;
public string cgbx;
public string cfue;
public string cvin;
public string cenn;
public string cccs;
public string cclr;
public string creg;
public string unam;
public string uloc;
public string upos;
public string uphn;
public string umob;
public string ueml;

public List<PartDetails> lParts = new List<PartDetails>();

static List<OrderDetails> ParseGetOrdersResult(string ReturnString)
List<OrderDetails> lRet = new List<OrderDetails>();
XmlDocument document = new XmlDocument();
ReturnString = ReturnString.Replace("&", "&amp;");
XmlNode root = document.DocumentElement;
XmlNodeList xmlOrders = root.SelectNodes("descendant::rq");
foreach (XmlNode order in xmlOrders)
catch (Exception ex)
string str = ex.Message;
//return error

return lRet;

static OrderDetails ParseOrderXML(XmlNode xmlOrder)
OrderDetails oRet = new OrderDetails();

XmlNode xmlOrDet01 = xmlOrder.SelectSingleNode("descendant::rfno");
oRet.rfno = xmlOrDet01.InnerText;
XmlNode xmlOrDet02 = xmlOrder.SelectSingleNode("descendant::date");
oRet.date = xmlOrDet02.InnerText;
XmlNode xmlOrDet03 = xmlOrder.SelectSingleNode("descendant::cdes");
oRet.cdes = xmlOrDet03.InnerText;
XmlNode xmlOrDet04 = xmlOrder.SelectSingleNode("descendant::cmak");
oRet.cmak = xmlOrDet04.InnerText;
XmlNode xmlOrDet05 = xmlOrder.SelectSingleNode("descendant::cran");
oRet.cran = xmlOrDet05.InnerText;
XmlNode xmlOrDet06 = xmlOrder.SelectSingleNode("descendant::cyer");
oRet.cyer = xmlOrDet06.InnerText;
XmlNode xmlOrDet07 = xmlOrder.SelectSingleNode("descendant::cbdy");
oRet.cbdy = xmlOrDet07.InnerText;
XmlNode xmlOrDet08 = xmlOrder.SelectSingleNode("descendant::cbdt");
oRet.cbdt = xmlOrDet08.InnerText;
XmlNode xmlOrDet09 = xmlOrder.SelectSingleNode("descendant::cgbx");
oRet.cgbx = xmlOrDet09.InnerText;
XmlNode xmlOrDet10 = xmlOrder.SelectSingleNode("descendant::cfue");
oRet.cfue = xmlOrDet10.InnerText;
XmlNode xmlOrDet11 = xmlOrder.SelectSingleNode("descendant::cvin");
oRet.cvin = xmlOrDet11.InnerText;
XmlNode xmlOrDet12 = xmlOrder.SelectSingleNode("descendant::cenn");
oRet.cenn = xmlOrDet12.InnerText;
XmlNode xmlOrDet13 = xmlOrder.SelectSingleNode("descendant::cccs");
oRet.cccs = xmlOrDet13.InnerText;
XmlNode xmlOrDet14 = xmlOrder.SelectSingleNode("descendant::cclr");
oRet.cclr = xmlOrDet14.InnerText;
XmlNode xmlOrDet15 = xmlOrder.SelectSingleNode("descendant::creg");
oRet.creg = xmlOrDet15.InnerText;
XmlNode xmlOrDet16 = xmlOrder.SelectSingleNode("descendant::unam");
oRet.unam = xmlOrDet16.InnerText;
XmlNode xmlOrDet17 = xmlOrder.SelectSingleNode("descendant::uloc");
oRet.uloc = xmlOrDet17.InnerText;
XmlNode xmlOrDet18 = xmlOrder.SelectSingleNode("descendant::upos");
oRet.upos = xmlOrDet18.InnerText;
XmlNode xmlOrDet19 = xmlOrder.SelectSingleNode("descendant::uphn");
oRet.uphn = xmlOrDet19.InnerText;
XmlNode xmlOrDet20 = xmlOrder.SelectSingleNode("descendant::umob");
oRet.umob = xmlOrDet20.InnerText;
XmlNode xmlOrDet21 = xmlOrder.SelectSingleNode("descendant::ueml");
oRet.ueml = xmlOrDet21.InnerText;

XmlNodeList xmlParts = xmlOrder.SelectNodes("descendant::part");
foreach (XmlNode xmlPart in xmlParts)
XmlNode xmlOrDet22 = xmlOrder.SelectSingleNode("descendant::pid");
XmlNode xmlOrDet23 = xmlOrder.SelectSingleNode("descendant::pdsc");
XmlNode xmlOrDet24 = xmlOrder.SelectSingleNode("descendant::pcmt");
oRet.lParts.Add(new PartDetails(xmlOrDet22.InnerText, xmlOrDet23.InnerText, xmlOrDet24.InnerText));

return oRet;

static void MakeQuote(string Username, string Password)
string request = "<quot rfno=\"2068421\" delp=\"840\" pcmt=\"my comment\" ccmt=\"comment for user\"><part pid=\"2663327\" gtm=\"3\" cnd=\"2\" prce=\"1200\" /></quot>";
string ReturnString = "";
wsSupplier.SupplierPub ws = new wsSupplier.SupplierPub();
ws.Url = wsUrl; ;
ReturnString = ws.MakeQuote(Username, Password, request);

Last edited by:

Andy: Nov 2, 2010, 12:32 PM

Edit Log: