martinblech / xmltodict

Python module that makes working with XML feel like you are working with JSON
MIT License
5.49k stars 462 forks source link

Unable to access nested parsed attributes #210

Open wfortuny opened 5 years ago

wfortuny commented 5 years ago

This could totally be me, I am really new to python and xmltodict. I am trying to parse a beerxml file. I am able to get to ['RECIPES']['RECIPE']['NAME'], but any deeper in the tree and I can't figure out how to access those elements, i.e. ['RECIPES']['RECIPE']['HOPS']['HOP']['NAME'] to get to the different hop types in the recipe. Here is a snippet and link to some additional XML files I'm using. And, I'm sorry if this has been answered before, I couldn't seem to find a solution anywhere.

http://www.beerxml.com/recipes.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

Festbier 1 All Grain 20.8197648 25.5136754 60.0000000 70.0000000 Select Spalt 1 Germany 0.7900000 0.1502524 Boil Bred from Hallertauer Mittelfrueh and Spalt in Germany. Spalt character. Used for: Lager, Pilsner, Noble aroma hop substitute Aroma: Very fine, spalt aroma Substitutes: Spalter, Saaz, Tettnang Aroma
Leaf
3.5000000 17.0000000 5.30 oz 0.00 oz 60.0 min
Mt. Hood 1 U.S. 1.0000000 0.1700970 Boil Used for: European Lagers, finishing Aroma: Mild with a clean aroma, neutral flavor. Somewhat pungent. Substitutes: Hallertauer, Liberty, Crystal Aroma
Leaf
6.3000000 40.0000000 6.00 oz 0.00 oz 10.0 min

Thank you.

Bill

wfortuny commented 5 years ago

XML File

Sorry, it looks like the XML code didn't keep the format when pasting it into the issue window.