...

View Full Version : reading values from non standard XML



kusky
09-02-2010, 09:39 PM
Hi All,

Im trying to write a html with javascript page that reads values from an XML file and outputs to a table. Thats easy i hear you say?

Trouble is the application that is outputing the XML file doesnt output a simple XML file.

Below is a section of the file:


<?xml version="1.0" encoding="UTF-8"?>
<CVES name="EUREX" datetime="09 Aug 10 14:40:41">
<thread name="DB 0" state ="active" nb="0" tempo="00:00:02" action="Wait"/>
<thread name="DB 1" state ="active" nb="0" tempo="00:00:02" action="Wait"/>
<thread name="match" state ="active" nb="0" tempo="00:00:02" action="Wait"/>
<MatchingList>
<Tickets value="142"/>
<TicketsCleared value="23"/>
<TicketsNotCleared value="119"/>
<Orders value="21"/>
<OrdersCleared value="21"/>
<OrdersNotCleared value="0"/>
</MatchingList>
<thread name="exch 1" state ="active" nb="0" tempo="00:00:10" action="Wait"/>
<Exchange>
<Tickets value="142"/>
<TicketsWithUnknownExternalCodes value="212"/>
<ClearingInProgress value="4"/>
<Clearing>
<AverageClearingTime value="00:00:00"/>
<LastClearingTime value="14:26:37"/>
<LastUnclearingTime value="14:27:55"/>
<TotalQtyCleared value="705"/>
<TotalQtyUnCleared value=""/>
</Clearing>
<Reading>
<LastReadingTime value="14:40:31"/>
<NextReadingTime value="14:41:00"/>


im able to read the contents of the CVES tag (Name and datetime) but cannot get any others to load.

how can i get details from LastReadingTime? Thread name="Exch 1"

Having googled reading XML into HTML file and cannot find anything that covers this kind of xml file

THanks

DaveyErwin
09-02-2010, 10:02 PM
Hi All,

Im trying to write a html with javascript page that reads values from an XML file and outputs to a table. Thats easy i hear you say?

Trouble is the application that is outputing the XML file doesnt output a simple XML file.

Below is a section of the file:


<?xml version="1.0" encoding="UTF-8"?>
<CVES name="EUREX" datetime="09 Aug 10 14:40:41">
<thread name="DB 0" state ="active" nb="0" tempo="00:00:02" action="Wait"/>
<thread name="DB 1" state ="active" nb="0" tempo="00:00:02" action="Wait"/>
<thread name="match" state ="active" nb="0" tempo="00:00:02" action="Wait"/>
<MatchingList>
<Tickets value="142"/>
<TicketsCleared value="23"/>
<TicketsNotCleared value="119"/>
<Orders value="21"/>
<OrdersCleared value="21"/>
<OrdersNotCleared value="0"/>
</MatchingList>
<thread name="exch 1" state ="active" nb="0" tempo="00:00:10" action="Wait"/>
<Exchange>
<Tickets value="142"/>
<TicketsWithUnknownExternalCodes value="212"/>
<ClearingInProgress value="4"/>
<Clearing>
<AverageClearingTime value="00:00:00"/>
<LastClearingTime value="14:26:37"/>
<LastUnclearingTime value="14:27:55"/>
<TotalQtyCleared value="705"/>
<TotalQtyUnCleared value=""/>
</Clearing>
<Reading>
<LastReadingTime value="14:40:31"/>
<NextReadingTime value="14:41:00"/>


im able to read the contents of the CVES tag (Name and datetime) but cannot get any others to load.

how can i get details from LastReadingTime? Thread name="Exch 1"

Having googled reading XML into HTML file and cannot find anything that covers this kind of xml file

THanks


<?xml version="1.0" encoding="UTF-8"?>
<CVES name="EUREX" datetime="09 Aug 10 14:40:41">
<thread name="DB 0" state ="active" nb="0" tempo="00:00:02" action="Wait"/>
<thread name="DB 1" state ="active" nb="0" tempo="00:00:02" action="Wait"/>
<thread name="match" state ="active" nb="0" tempo="00:00:02" action="Wait"/>
<MatchingList>
<Tickets value="142"/>
<TicketsCleared value="23"/>
<TicketsNotCleared value="119"/>
<Orders value="21"/>
<OrdersCleared value="21"/>
<OrdersNotCleared value="0"/>
</MatchingList>
<thread name="exch 1" state ="active" nb="0" tempo="00:00:10" action="Wait"/>
<Exchange>
<Tickets value="142"/>
<TicketsWithUnknownExternalCodes value="212"/>
<ClearingInProgress value="4"/>
<Clearing>
<AverageClearingTime value="00:00:00"/>
<LastClearingTime value="14:26:37"/>
<LastUnclearingTime value="14:27:55"/>
<TotalQtyCleared value="705"/>
<TotalQtyUnCleared value=""/>
</Clearing>
<Reading>
<LastReadingTime value="14:40:31"/>
<NextReadingTime value="14:41:00"/>
</Reading>
</Exchange>
</CVES >

maybe just fix your xml as above

But thats not all of the file is it.

maybe if we saw the whole file it would
be xml ?

kuskyboy
09-02-2010, 10:26 PM
sorry here is the full file



<?xml version="1.0" encoding="UTF-8"?>
<CVES name="EUREX" datetime="09 Aug 10 14:40:41" gays="IOAN">
<thread name="DB 0" state ="active" nb="0" tempo="00:00:02" action="Wait"/>
<thread name="DB 1" state ="active" nb="0" tempo="00:00:02" action="Wait"/>
<thread name="match" state ="active" nb="0" tempo="00:00:02" action="Wait"/>
<MatchingList>
<Tickets value="142"/>
<TicketsCleared value="23"/>
<TicketsNotCleared value="119"/>
<Orders value="21"/>
<OrdersCleared value="21"/>
<OrdersNotCleared value="0"/>
</MatchingList>
<thread name="exch 1" state ="active" nb="0" tempo="00:00:10" action="Wait"/>
<Exchange>
<Tickets value="142"/>
<TicketsWithUnknownExternalCodes value="212"/>
<ClearingInProgress value="4"/>
<Clearing>
<AverageClearingTime value="00:00:00"/>
<LastClearingTime value="14:26:37"/>
<LastUnclearingTime value="14:27:55"/>
<TotalQtyCleared value="705"/>
<TotalQtyUnCleared value=""/>
</Clearing>
<Reading>
<LastReadingTime value="14:40:31"/>
<NextReadingTime value="14:41:00"/>
<AverageReadingTime value="00:00:00"/>
<TicketRead value="142"/>
</Reading>
</Exchange>
<thread name="netw" state ="active" nb="0" tempo="00:12:40" action="Wait"/>
<RDBMS>
<LastSQLError value="10:56:48 insert into CV_ORDER (IDXO,MARKET,BS,FDISABLE,JOBOUT,XGM,OPERATOR,TRADER,ORDERNUM,CONTRACT,CTRTYPE,OPTFUT,BROKER,CLEARING INFO,REFINTERNE,ORDERTYPE,PRICE,STRIKE,DELIVERY,DATEOP,STAMPTIME,HHCREATION,HHUPDATE,SOURCE,EXECDATE ,TRADETYPE,FREE1,FREE2,FREE3,FREE4,FREE5) values (:b0,:b1,:b2,:b3,:b4"/>
</RDBMS>
</CVES>

DaveyErwin
09-02-2010, 10:31 PM
I stuck that in firefox and firefox thiught it was good xml
at least it didn't complain any.

kuskyboy
09-02-2010, 11:02 PM
i am in no doubt it is good XML.

Ill try and explain the issue.

When i try and load data from the above XML document i am only able to display the contents of two areas
name="EUREX" datetime="09 Aug 10 14:40:41"

I need to get the infomation from other areas of the XML file (EG the contents of the value in <AverageClearingTime value="00:00:00"/>

CAn someone suggest the best way to get these types of details from the above file and into a HTML table? Or a link so a topic that will explain this?

Thanks

Old Pedant
09-03-2010, 03:26 AM
Well, you can always do


var act = xml.getElementsByTagName("AverageClearingTime")[0];
var actValue = act.getAttribute("value");

or similar.

http://www.w3schools.com/Dom/met_element_getattribute.asp

DaveyErwin
09-03-2010, 03:48 AM
Well, you can always do


var act = xml.getElementsByTagName("AverageClearingTime")[0];
var actValue = act.getAttribute("value");

or similar.

http://www.w3schools.com/Dom/met_element_getattribute.asp

Just looking for your advice , shouldn't we
start a new thread called reading xml ?

kuskyboy
09-06-2010, 11:45 AM
thanks for the info Old Pendant, will take a look at the things on w3schools and give it a go



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum