Reading values from a XML File

from this file i want to read the values from <model> tag using a for loop
help me with code. i don’t know xml well.

thank u

  • <cat-product-structure>
  • <Product_Group>
    <ProductGroup>DI</ProductGroup>
    <Description>Digital Images</Description>
  • <Category>
    <PrimaryCat>DSC</PrimaryCat>
    <Description>Digital Still Camera</Description>
    <CatCaption>Welcome to xxxx Digtial Images Product Line up 2004</CatCaption>
    <CatWelcomeNote>Welcome to xxxx Digtial Images Product Line up 2004 … A detailed discription goes here … many lines</CatWelcomeNote>
    <CatPictureName>digitalImages.jpg</CatPictureName>
  • <compare_features>
    <specname>Lens construction</specname>
    <specname>Optical Zoom</specname>
    <specname>Precision Digital Zoom</specname>
    <specname>Smart Zoom</specname>
    <specname>Focal length f=(35mm conversion)</specname>
    </compare_features>
  • <Sub-Category>
    <SecondaryCat>Cyber-shot</SecondaryCat>
    <Description>Cyber-shot</Description>
    <CatCaption>Welcome to xxxx Cybershot Digtial Camera Product Line up 2004</CatCaption>
    <CatWelcomeNote>Welcome to xxxx Cybershot Digtial Camera Product Line up 2004 … A detailed discription goes here … many lines</CatWelcomeNote>
    <CatPictureName>cybershot.jpg</CatPictureName>
  • <compare_features>
    <specname>Lens construction</specname>
    <specname>Optical Zoom</specname>
    <specname>Precision Digital Zoom</specname>
    <specname>Smart Zoom</specname>
    <specname>Focal length f=(35mm conversion)</specname>
    </compare_features>
  • <Models>
  • <Modelname Name=“DSC-T1”>
    <Description>DSC-T1</Description>
    <ModelCaption />
    <ModelWelcomeNote />
    <FeaturedFlag>Yes</FeaturedFlag>
    <NewFlag>No</NewFlag>
    <Currency>SGD</Currency>
    <Price>110.00</Price>
    <modelpicturename />
    <specification_code code=“E32” />
  • <compare_features>
    <specname>Lens construction</specname>
    <value>5 elements in 4 groups(including 1 aspheric elements)</value>
    <specname>Optical Zoom</specname>
    <value>1x</value>
    <specname>Precision Digital Zoom</specname>
    <value>No</value>
    <specname>Smart Zoom</specname>
    <value>No</value>
    <specname>Focal length f=(35mm conversion)</specname>
    <value>f=5mm(33mm)</value>
    </compare_features>
  • <unique_features>
    <specname>Optical Zoom</specname>
    <value>1x</value>
    <specname>Gross Pixels</specname>
    <value>Approx2,110KPixels</value>
    <specname>Effective Pixels</specname>
    <value>Approx2,020KPixels</value>
    <specname>Recording Format</specname>
    <value>JPEG MPEG</value>
    <specname>Playback Still Image Size</specname>
    <value>640x480 1,280x960 1,600x1,200 1,632x1,224</value>
    </unique_features>
    </Modelname>
  • <Modelname Name=“DSC-U40”>
    <Description>DSC-U40</Description>
    <ModelCaption />
    <ModelWelcomeNote />
    <FeaturedFlag>Yes</FeaturedFlag>
    <NewFlag>No</NewFlag>
    <Currency>SGD</Currency>
    <Price>110.00</Price>
    <modelpicturename />
    <specification_code code=“E32” />
  • <compare_features>
    <specname>Lens construction</specname>
    <value>5 elements in 4 groups(including 1 aspheric elements)</value>
    <specname>Optical Zoom</specname>
    <value>1x</value>
    <specname>Precision Digital Zoom</specname>
    <value>No</value>
    <specname>Smart Zoom</specname>
    <value>No</value>
    <specname>Focal length f=(35mm conversion)</specname>
    <value>f=5mm(33mm)</value>
    </compare_features>
  • <unique_features>
    <specname>Optical Zoom</specname>
    <value>1x</value>
    <specname>Gross Pixels</specname>
    <value>Approx2,110KPixels</value>
    <specname>Effective Pixels</specname>
    <value>Approx2,020KPixels</value>
    <specname>Recording Format</specname>
    <value>JPEG MPEG</value>
    <specname>Playback Still Image Size</specname>
    <value>640x480 1,280x960 1,600x1,200 1,632x1,224</value>
    </unique_features>
    </Modelname>
    </Models>
    </Sub-Category>
  • <Sub-Category>
    <SecondaryCat>Mavica</SecondaryCat>
    <Description>Mavica</Description>
    <CatCaption>Welcome to xxxx Mavica Ditial Camera Product Line up 2004</CatCaption>
    <CatWelcomeNote>Welcome to xxxx Mavica Ditial Camera Product Line up 2004 … A detailed discription goes here … many lines</CatWelcomeNote>
    <CatPictureName>Mavica.jpg</CatPictureName>
  • <compare_features>
    <specname>Lens construction</specname>
    <specname>Optical Zoom</specname>
    <specname>Precision Digital Zoom</specname>
    <specname>Smart Zoom</specname>
    <specname>Focal length f=(35mm conversion)</specname>
    </compare_features>
  • <Models>
  • <Modelname Name=“MVC-FD100”>
    <Description>MVC-FD100</Description>
    <ModelCaption />
    <ModelWelcomeNote />
    <FeaturedFlag>Yes</FeaturedFlag>
    <NewFlag>No</NewFlag>
    <Currency>SGD</Currency>
    <Price>110.00</Price>
    <modelpicturename />
    <specification_code code=“E32” />
  • <compare_features>
    <specname>Lens construction</specname>
    <value>5 elements in 4 groups(including 1 aspheric elements)</value>
    <specname>Optical Zoom</specname>
    <value>1x</value>
    <specname>Precision Digital Zoom</specname>
    <value>No</value>
    <specname>Smart Zoom</specname>
    <value>No</value>
    <specname>Focal length f=(35mm conversion)</specname>
    <value>f=5mm(33mm)</value>
    </compare_features>
  • <unique_features>
    <specname>Optical Zoom</specname>
    <value>1x</value>
    <specname>Gross Pixels</specname>
    <value>Approx2,110KPixels</value>
    <specname>Effective Pixels</specname>
    <value>Approx2,020KPixels</value>
    <specname>Recording Format</specname>
    <value>JPEG MPEG</value>
    <specname>Playback Still Image Size</specname>
    <value>640x480 1,280x960 1,600x1,200 1,632x1,224</value>
    </unique_features>
    </Modelname>
  • <Modelname Name=“MVC-CD400”>
    <Description>MVC-CD400</Description>
    <ModelCaption />
    <ModelWelcomeNote />
    <FeaturedFlag>Yes</FeaturedFlag>
    <NewFlag>No</NewFlag>
    <Currency>SGD</Currency>
    <Price>110.00</Price>
    <modelpicturename />
    <specification_code code=“E32” />
  • <compare_features>
    <specname>Lens construction</specname>
    <value>5 elements in 4 groups(including 1 aspheric elements)</value>
    <specname>Optical Zoom</specname>
    <value>1x</value>
    <specname>Precision Digital Zoom</specname>
    <value>No</value>
    <specname>Smart Zoom</specname>
    <value>No</value>
    <specname>Focal length f=(35mm conversion)</specname>
    <value>f=5mm(33mm)</value>
    </compare_features>
  • <unique_features>
    <specname>Optical Zoom</specname>
    <value>1x</value>
    <specname>Gross Pixels</specname>
    <value>Approx2,110KPixels</value>
    <specname>Effective Pixels</specname>
    <value>Approx2,020KPixels</value>
    <specname>Recording Format</specname>
    <value>JPEG MPEG</value>
    <specname>Playback Still Image Size</specname>
    <value>640x480 1,280x960 1,600x1,200 1,632x1,224</value>
    </unique_features>
    </Modelname>
    </Models>
    </Sub-Category>
    </Category>
    </Product_Group>
    </cat-product-structure>

we have tutorials for this kind of thing
http://www.kirupa.com/web/xml/

this is the code i wrote but i am getting only second sub category values i think there is some problem in my loops please correct it. thanks for ur great tutorial

newRelease_xml = new XML();
newRelease_xml.ignoreWhite = true;
newRelease_xml.onLoad = function(success) {
if (success) {
ShowNewReleases(newRelease_xml);
} else {
trace(“Error! loading xml…”);
}
};
newRelease_xml.load(“cat-product-structure.xml”);
ShowNewReleases = function (node_xml) {
var x = 0;
var y = 36;
category = node_xml.firstChild.firstChild.childNodes[2];
container = this.createEmptyMovieClip(“cont”, 100);
for (var i = 0; i<=category.childNodes.length; i++) {
if (category.childNodes*.nodeName == “Sub-Category”){
for (var j=0; j<=category.childNodes*.childNodes.length; j++) {
if (category.childNodes*.childNodes[j].nodeName == “Models”) {
for (k=0; k<4; k++){
if(category.childNodes*.childNodes[j].childNodes[k].childNodes[4].firstChild.nodeValue==“No”){
curr_item = container.attachMovie(“newRelease”, “newR”+k, k10);
curr_item._x = x+k
curr_item._width;
curr_item._y = y;
curr_item.title = category.childNodes*.childNodes[j].childNodes[k].attributes.Name;
curr_item.info = category.childNodes*.childNodes[j].childNodes[k].firstChild.firstChild.nodeValue;
image = category.childNodes*.childNodes[j].childNodes[k].childNodes[7].attributes.path;

					trace(image);
				    curr_item.image.loadMovie(image);
					
					}
					
				}
			}
		}
	}
}

};