SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to parse dynamic XML content into html tables nicely with 1 second REFRESH rate?

    Hi Everyone,

    I have been playing with JavaScript few days now. I have a php script that returns data in XML. I want my Dashboard (html) page to show the response back from my php file. Since this is going to be a Dashboard hence it needs to refresh the content every second hence using JavaScript.

    I want to get some guides, tutorials, or how-to for this. Any help would be much appreciated.

    Here is what I get from my .php file if I do a POST method to it and define variable "extension=9999" to it:

    Code XML:
    <?xml version="1.0" encoding="utf-8"?> 
    <reseller> 
    	<history> 
    		<extension>9999</extension> 
    		<duration>0</duration> 
    		<cost>0</cost> 
    	</history> 
    	<history> 
    		<extension>9999</extension> 
    		<duration>0</duration> 
    		<cost>0</cost> 
    	</history> 
    	<history> 
    		<extension>9999</extension> 
    		<duration>1</duration> 
    		<cost>9</cost> 
    	</history> 
    	<history> 
    		<extension>9999</extension> 
    		<duration>0</duration> 
    		<cost>0</cost> 
    	</history> 
    	<history> 
    		<extension>9999</extension> 
    		<duration>0</duration> 
    		<cost>0</cost> 
    	</history> 
    	<history> 
    		<extension>9999</extension> 
    		<duration>0</duration> 
    		<cost>0</cost> 
    	</history> 
    </reseller>

    How can above be nicely presented in an HTML using JavaScript and how would this query be refreshed and re-POSTED every 1 second?

    P.S. Amount of XML data coming back to me is dynamic. So, I don't know how much data I get back. Sometime nothing. Sometime 4 childs. Sometime 10 childs in the XML.

    thanks very much
    Last edited by Mittineague; Apr 15, 2011 at 11:22. Reason: reformatting bbcode tags

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Here's an article that explains how it can be done.
    Using XML Data Traversal SitePoint Blogs
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot.

    Few things though.

    1- It's not doing a POST method to get data.
    2- It works only in IE? Am I right with that assumption?
    3- It doesn't refresh every 1 second.

    Can you please shed some light on the above 3. I have used quite a few scripts like this but I am failing when I try to enhance them to POST method or Refresh every second....

    Thanks

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by torontob@mailina View Post
    I have used quite a few scripts like this but I am failing when I try to enhance them to POST method or Refresh every second....
    Have you considered using a code library such as jQuery to help remove the complexity for you?
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think this is that complex as jQuery might yet get me into another learning curve. I would like to have a quicker turn around time for this.

    It just that JavaScript is not anything like PHP :-) and I don't have much experience with it.

  6. #6
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by torontob@mailina View Post
    I don't think this is that complex as jQuery might yet get me into another learning curve. I would like to have a quicker turn around time for this.
    Keep in mind that we are all volunteers here. I am heading off in the next hour or so, so won't be able to help significantly with your issue. I might see though if I can put something together when I return tomorrow, but even so it would be to guide you through what's needed, so that you can learn from the process of doing it too.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  7. #7
    SitePoint Member
    Join Date
    Apr 2011
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, I definitely appreciate all the guide from you. And definitely want to learn the processes rather than copying my work.

    But for some reason JavaScript is really not my thing :-) I don't know why it's has such an ugly syntax (no offense to anyone who likes JavaScript). I think that plays into my not being so motivated on it. But again not a lot of resources on JavaScript are available like is on PHP, HTML, etc...

    In the meanwhile I will do a bit searching on jQuery as well.

    Regards,


Bookmarks

Posting Permissions

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