Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation reading values from non standard XML

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

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    966
    Thanks
    19
    Thanked 211 Times in 209 Posts
    Quote Originally Posted by kusky View Post
    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:
    Code:
    <?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
    Code:
    <?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 ?

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry here is the full file

    Code:
    <?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,CLEARINGINFO,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>

  • #4
    Regular Coder
    Join Date
    Aug 2010
    Posts
    966
    Thanks
    19
    Thanked 211 Times in 209 Posts
    I stuck that in firefox and firefox thiught it was good xml
    at least it didn't complain any.

  • #5
    New Coder
    Join Date
    Mar 2005
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,023
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Well, you can always do
    Code:
    var act = xml.getElementsByTagName("AverageClearingTime")[0];
    var actValue = act.getAttribute("value");
    or similar.

    http://www.w3schools.com/Dom/met_ele...tattribute.asp
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Regular Coder
    Join Date
    Aug 2010
    Posts
    966
    Thanks
    19
    Thanked 211 Times in 209 Posts
    Quote Originally Posted by Old Pedant View Post
    Well, you can always do
    Code:
    var act = xml.getElementsByTagName("AverageClearingTime")[0];
    var actValue = act.getAttribute("value");
    or similar.

    http://www.w3schools.com/Dom/met_ele...tattribute.asp
    Just looking for your advice , shouldn't we
    start a new thread called reading xml ?

  • #8
    New Coder
    Join Date
    Mar 2005
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the info Old Pendant, will take a look at the things on w3schools and give it a go


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •