lollerskates
Programmer
Hi there
I have an XML file that looks like this:
Within delphi I am using TXMLDocument and I have a series of TImage holders for the images to load into. Currently I am loading in the first image using this code:
That works fine. What I need to do now though is expand the code so that all of the images are loaded. I've always had a problem with 'for' loops and arrays and I'm pretty sure that's what's needed here.
I need to determine how many child nodes there are and also check if the <image> tag contains an image rather than being blank (because the XML file is going to be extended to include text in addition to the caption - so one of the child nodes may be like this:
Then I need the image in the first child node to load into the first image holder, the 2nd into the 2nd image holder etc. If the 3rd one doesn't contain an image I just want the 3rd image holder to be blank and continue checking the 4th node for an image right up to the end of the XML file.
*gulp*
Any help with this would be really really appreciated! Thank you!
I have an XML file that looks like this:
Code:
<album>
<slide>
<image>img01.jpg</image>
<caption>Image 1</caption>
</slide>
<slide>
<image>img02.jpg</image>
<caption>Image 2</caption>
</slide>
</album>
Within delphi I am using TXMLDocument and I have a series of TImage holders for the images to load into. Currently I am loading in the first image using this code:
Code:
myXML := images.DocumentElement.ChildNodes[0];
Image1.picture.loadfromfile(myXML.ChildNodes['image'].NodeValue);
That works fine. What I need to do now though is expand the code so that all of the images are loaded. I've always had a problem with 'for' loops and arrays and I'm pretty sure that's what's needed here.
I need to determine how many child nodes there are and also check if the <image> tag contains an image rather than being blank (because the XML file is going to be extended to include text in addition to the caption - so one of the child nodes may be like this:
Code:
<image></image>
<caption></caption>
<text>some text here</text>
Then I need the image in the first child node to load into the first image holder, the 2nd into the 2nd image holder etc. If the 3rd one doesn't contain an image I just want the 3rd image holder to be blank and continue checking the 4th node for an image right up to the end of the XML file.
*gulp*
Any help with this would be really really appreciated! Thank you!