Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. XML file read images and display them at random

XML file read images and display them at random

Scheduled Pinned Locked Moved XML / XSL
helptutorialjavascripthtmlxml
4 Posts 2 Posters 43 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eatupyourgreens
    wrote on last edited by
    #1

    Hello! I'm really desperate. I also googled and tried examples, which did not work in the end. I'm also a beginner in XML / Javascript and have very little XML knowledge. That's why I really ask for your help / explanation. Following problem: I need an XML file that contains several images. In the HTML file, these images should then be read randomly from the XML file. Coincidentally in this sense, for example, that you specify 20 images in the XML file, but only 10 random images are displayed in the HTML file. I really do not know how to do that. I've also read websites, but I'm still not smart. I would be very happy about an example so that I understand it firstly and secondly apply it. Besides, I do not know how to place these pictures in a particular place. It should be such that e.g. Image 1 is located at xy, while image 2 is to be displayed elsewhere on the site. How should I write the code so that it is output? Is that even possible? I guess it will probably be easy, but I can not get on with it. I would be very happy to receive answers :)

    L 1 Reply Last reply
    0
    • E eatupyourgreens

      Hello! I'm really desperate. I also googled and tried examples, which did not work in the end. I'm also a beginner in XML / Javascript and have very little XML knowledge. That's why I really ask for your help / explanation. Following problem: I need an XML file that contains several images. In the HTML file, these images should then be read randomly from the XML file. Coincidentally in this sense, for example, that you specify 20 images in the XML file, but only 10 random images are displayed in the HTML file. I really do not know how to do that. I've also read websites, but I'm still not smart. I would be very happy about an example so that I understand it firstly and secondly apply it. Besides, I do not know how to place these pictures in a particular place. It should be such that e.g. Image 1 is located at xy, while image 2 is to be displayed elsewhere on the site. How should I write the code so that it is output? Is that even possible? I guess it will probably be easy, but I can not get on with it. I would be very happy to receive answers :)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      XML is not an ideal vehicle for transmitting images, which would need to be encoded as some textual representation first. A better idea would be to use a database or just a directory with the images stored as files. As for displaying information via HTML/Javascript, you can find examples all over the internet. A good starting point would be W3Schools Online Web Tutorials[^]

      E 1 Reply Last reply
      0
      • L Lost User

        XML is not an ideal vehicle for transmitting images, which would need to be encoded as some textual representation first. A better idea would be to use a database or just a directory with the images stored as files. As for displaying information via HTML/Javascript, you can find examples all over the internet. A good starting point would be W3Schools Online Web Tutorials[^]

        E Offline
        E Offline
        eatupyourgreens
        wrote on last edited by
        #3

        Thank you for your answer! I have already implemented this with HTML and it works, but unfortunately it is required that the images can be read from an XML file. Something other than an XML file is not accepted. And that's my problem .. how could I solve this if nothing but an XML file is allowed?

        L 1 Reply Last reply
        0
        • E eatupyourgreens

          Thank you for your answer! I have already implemented this with HTML and it works, but unfortunately it is required that the images can be read from an XML file. Something other than an XML file is not accepted. And that's my problem .. how could I solve this if nothing but an XML file is allowed?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Like I said, you will need to encode the image files into text and then decode them in the HTML handler. See xml encode binary - Google Search[^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups