C
Charlie@CBFC
Hi:
I'm trying to loop through an XML document but ChildNodes property reports
only one node, but there are many. XML document is valid. What am I doing
wrong?
foreach( XmlNode node in xml.ChildNodes ) { }
Below is XML...
<Catalog>
<Category>
<CategoryName>Drivers</CategoryName>
<Subcategory>
<SubcategoryName>Tweeters</SubcategoryName>
<SubCategorySubCategory>
<SubCategorySubCategoryName>.5 inch Dome
Tweeters</SubCategorySubCategoryName>
<Product>
<ShortDescription>.5 Metal Dome Tweeter</ShortDescription>
<Price>25.9600</Price>
</Product>
</SubCategorySubCategory>
<SubCategorySubCategory>
<SubCategorySubCategoryName>.75 inch Dome
Tweeters</SubCategorySubCategoryName>
<Product>
<ShortDescription>.75 Fabric Dome Tweeter</ShortDescription>
<Price>28.9900</Price>
</Product>
</SubCategorySubCategory>
<SubCategorySubCategory>
<SubCategorySubCategoryName>1 inch Dome
Tweeters</SubCategorySubCategoryName>
<Product>
<ShortDescription>1 Fabric Dome Tweeter</ShortDescription>
<Price>55.0000</Price>
</Product>
<Product>
<ShortDescription>1 Meal Dome Tweeter</ShortDescription>
<Price>44.0000</Price>
</Product>
</SubCategorySubCategory>
</Subcategory>
<Subcategory>
<SubcategoryName>Mid-Ranges</SubcategoryName>
<SubCategorySubCategory>
<SubCategorySubCategoryName>5.25 inch
Mid-Ranges</SubCategorySubCategoryName>
<Product>
<ShortDescription>5.25 Poly Mid-range</ShortDescription>
<Price>55.0000</Price>
</Product>
</SubCategorySubCategory>
<SubCategorySubCategory>
<SubCategorySubCategoryName>3 inch Dome
Mid-Ranges</SubCategorySubCategoryName>
<Product>
<ShortDescription>3 Metal Dome Mid-range</ShortDescription>
<Price>89.5000</Price>
</Product>
</SubCategorySubCategory>
</Subcategory>
<Subcategory>
<SubcategoryName>Woofers</SubcategoryName>
<SubCategorySubCategory>
<SubCategorySubCategoryName>6.5 inch Woofers</SubCategorySubCategoryName>
<Product>
<ShortDescription>6.5 Paper Cone Woofer</ShortDescription>
<Price>125.0000</Price>
</Product>
</SubCategorySubCategory>
<SubCategorySubCategory>
<SubCategorySubCategoryName>10 inch Woofers</SubCategorySubCategoryName>
<Product>
<ShortDescription>10 Poly Cone Woofer</ShortDescription>
<Price>175.0000</Price>
</Product>
</SubCategorySubCategory>
</Subcategory>
</Category>
<Category>
<CategoryName>Electrical Components</CategoryName>
<Subcategory>
<SubcategoryName>Resistors</SubcategoryName>
<SubCategorySubCategory>
<SubCategorySubCategoryName>Metal Film
Resistors</SubCategorySubCategoryName>
<Product>
<ShortDescription>220 ohm Metal Film</ShortDescription>
<Price>0.2500</Price>
</Product>
<Product>
<ShortDescription>300 ohm Metal Film</ShortDescription>
<Price>0.2500</Price>
</Product>
<Product>
<ShortDescription>500 ohm Metal Film</ShortDescription>
<Price>0.2500</Price>
</Product>
</SubCategorySubCategory>
<SubCategorySubCategory>
<SubCategorySubCategoryName>Carbon Resistors</SubCategorySubCategoryName>
<Product>
<ShortDescription>300 ohm Carbon</ShortDescription>
<Price>0.1500</Price>
</Product>
<Product>
<ShortDescription>220 ohm Carbon</ShortDescription>
<Price>0.1500</Price>
</Product>
<Product>
<ShortDescription>500 ohm Carbon</ShortDescription>
<Price>0.1500</Price>
</Product>
</SubCategorySubCategory>
</Subcategory>
<Subcategory>
<SubcategoryName>Capacitors</SubcategoryName>
<SubCategorySubCategory>
<SubCategorySubCategoryName>Bi-Polar Capacitors</SubCategorySubCategoryName>
<Product>
<ShortDescription>10 uF Bi-Polar</ShortDescription>
<Price>0.1500</Price>
</Product>
<Product>
<ShortDescription>12 uF Bi-Polar</ShortDescription>
<Price>0.1500</Price>
</Product>
<Product>
<ShortDescription>15 uF Bi-Polar</ShortDescription>
<Price>0.1500</Price>
</Product>
</SubCategorySubCategory>
<SubCategorySubCategory>
<SubCategorySubCategoryName>Non-Polarized
Capacitors</SubCategorySubCategoryName>
<Product>
<ShortDescription>.15 uF Poly</ShortDescription>
<Price>0.9900</Price>
</Product>
<Product>
<ShortDescription>.35 uF Poly</ShortDescription>
<Price>1.5000</Price>
</Product>
<Product>
<ShortDescription>.0015 uF Poly</ShortDescription>
<Price>2.9500</Price>
</Product>
</SubCategorySubCategory>
</Subcategory>
</Category>
</Catalog>
Thanks,
Charlie
I'm trying to loop through an XML document but ChildNodes property reports
only one node, but there are many. XML document is valid. What am I doing
wrong?
foreach( XmlNode node in xml.ChildNodes ) { }
Below is XML...
<Catalog>
<Category>
<CategoryName>Drivers</CategoryName>
<Subcategory>
<SubcategoryName>Tweeters</SubcategoryName>
<SubCategorySubCategory>
<SubCategorySubCategoryName>.5 inch Dome
Tweeters</SubCategorySubCategoryName>
<Product>
<ShortDescription>.5 Metal Dome Tweeter</ShortDescription>
<Price>25.9600</Price>
</Product>
</SubCategorySubCategory>
<SubCategorySubCategory>
<SubCategorySubCategoryName>.75 inch Dome
Tweeters</SubCategorySubCategoryName>
<Product>
<ShortDescription>.75 Fabric Dome Tweeter</ShortDescription>
<Price>28.9900</Price>
</Product>
</SubCategorySubCategory>
<SubCategorySubCategory>
<SubCategorySubCategoryName>1 inch Dome
Tweeters</SubCategorySubCategoryName>
<Product>
<ShortDescription>1 Fabric Dome Tweeter</ShortDescription>
<Price>55.0000</Price>
</Product>
<Product>
<ShortDescription>1 Meal Dome Tweeter</ShortDescription>
<Price>44.0000</Price>
</Product>
</SubCategorySubCategory>
</Subcategory>
<Subcategory>
<SubcategoryName>Mid-Ranges</SubcategoryName>
<SubCategorySubCategory>
<SubCategorySubCategoryName>5.25 inch
Mid-Ranges</SubCategorySubCategoryName>
<Product>
<ShortDescription>5.25 Poly Mid-range</ShortDescription>
<Price>55.0000</Price>
</Product>
</SubCategorySubCategory>
<SubCategorySubCategory>
<SubCategorySubCategoryName>3 inch Dome
Mid-Ranges</SubCategorySubCategoryName>
<Product>
<ShortDescription>3 Metal Dome Mid-range</ShortDescription>
<Price>89.5000</Price>
</Product>
</SubCategorySubCategory>
</Subcategory>
<Subcategory>
<SubcategoryName>Woofers</SubcategoryName>
<SubCategorySubCategory>
<SubCategorySubCategoryName>6.5 inch Woofers</SubCategorySubCategoryName>
<Product>
<ShortDescription>6.5 Paper Cone Woofer</ShortDescription>
<Price>125.0000</Price>
</Product>
</SubCategorySubCategory>
<SubCategorySubCategory>
<SubCategorySubCategoryName>10 inch Woofers</SubCategorySubCategoryName>
<Product>
<ShortDescription>10 Poly Cone Woofer</ShortDescription>
<Price>175.0000</Price>
</Product>
</SubCategorySubCategory>
</Subcategory>
</Category>
<Category>
<CategoryName>Electrical Components</CategoryName>
<Subcategory>
<SubcategoryName>Resistors</SubcategoryName>
<SubCategorySubCategory>
<SubCategorySubCategoryName>Metal Film
Resistors</SubCategorySubCategoryName>
<Product>
<ShortDescription>220 ohm Metal Film</ShortDescription>
<Price>0.2500</Price>
</Product>
<Product>
<ShortDescription>300 ohm Metal Film</ShortDescription>
<Price>0.2500</Price>
</Product>
<Product>
<ShortDescription>500 ohm Metal Film</ShortDescription>
<Price>0.2500</Price>
</Product>
</SubCategorySubCategory>
<SubCategorySubCategory>
<SubCategorySubCategoryName>Carbon Resistors</SubCategorySubCategoryName>
<Product>
<ShortDescription>300 ohm Carbon</ShortDescription>
<Price>0.1500</Price>
</Product>
<Product>
<ShortDescription>220 ohm Carbon</ShortDescription>
<Price>0.1500</Price>
</Product>
<Product>
<ShortDescription>500 ohm Carbon</ShortDescription>
<Price>0.1500</Price>
</Product>
</SubCategorySubCategory>
</Subcategory>
<Subcategory>
<SubcategoryName>Capacitors</SubcategoryName>
<SubCategorySubCategory>
<SubCategorySubCategoryName>Bi-Polar Capacitors</SubCategorySubCategoryName>
<Product>
<ShortDescription>10 uF Bi-Polar</ShortDescription>
<Price>0.1500</Price>
</Product>
<Product>
<ShortDescription>12 uF Bi-Polar</ShortDescription>
<Price>0.1500</Price>
</Product>
<Product>
<ShortDescription>15 uF Bi-Polar</ShortDescription>
<Price>0.1500</Price>
</Product>
</SubCategorySubCategory>
<SubCategorySubCategory>
<SubCategorySubCategoryName>Non-Polarized
Capacitors</SubCategorySubCategoryName>
<Product>
<ShortDescription>.15 uF Poly</ShortDescription>
<Price>0.9900</Price>
</Product>
<Product>
<ShortDescription>.35 uF Poly</ShortDescription>
<Price>1.5000</Price>
</Product>
<Product>
<ShortDescription>.0015 uF Poly</ShortDescription>
<Price>2.9500</Price>
</Product>
</SubCategorySubCategory>
</Subcategory>
</Category>
</Catalog>
Thanks,
Charlie