<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:inherit;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"inherit",serif;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"inherit",serif;}
span.od
{mso-style-name:od;}
span.ev
{mso-style-name:ev;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal><o:p> </o:p></p><table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0><tr><td style='padding:0in 0in 0in 0in'><div style='border:solid windowtext 1.0pt;padding:1.0pt 1.0pt 1.0pt 1.0pt' id=vt100><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'>import xml.etree.ElementTree </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=ev><span style='color:#BFBFBF'>from bs4 import BeautifulSoup </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'> </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=ev><span style='color:#BFBFBF'>soup = xml.etree.ElementTree.parse(open("../../../../../../specifications/X3dUni</span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'>fiedObjectModel-3.3.xml")).getroot() </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=ev><span style='color:#BFBFBF'>bsoup = BeautifulSoup(open("../../../../../../specifications/X3dUnifiedObjectMod</span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'>el-3.3.xml"), "xml") </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=ev><span style='color:#BFBFBF'> </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'>print("BeautifulSoup==========================================================")</span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=ev><span style='color:#BFBFBF'>cns = bsoup.find_all("ConcreteNode") </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'>for cn in cns: </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=ev><span style='color:#BFBFBF'> print(cn["name"]+" component is") </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'> print(cn.find("componentInfo")["name"]) </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=ev><span style='color:#BFBFBF'> </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'>print("ElementTree==========================================================") </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=ev><span style='color:#BFBFBF'>cns = soup.iter("ConcreteNode") </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'>for cn in cns: </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=ev><span style='color:#BFBFBF'> print(cn.get("name")+" component is") </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'> print(cn.find("componentInfo").get("name")) </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre></div></td></tr></table><table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0><tr><td style='padding:0in 0in 0in 0in'><div style='border:solid windowtext 1.0pt;padding:1.0pt 1.0pt 1.0pt 1.0pt' id=vt100><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'>Snip<o:p></o:p></span></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'><o:p> </o:p></span></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'>ElementTree========================================================== </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=ev><span style='color:#BFBFBF'>Anchor component is </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'>Traceback (most recent call last): </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=ev><span style='color:#BFBFBF'> File "pythonerror.py", line 17, in </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'> print(cn.find("componentInfo").get("name")) </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre><pre style='line-height:111%;background:black'><span class=ev><span style='color:#BFBFBF'>AttributeError: 'NoneType' object has no attribute 'get' </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre></div></td></tr></table><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Apparently find does not find grand children as this code works:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0><tr><td style='padding:0in 0in 0in 0in'><div style='border:solid windowtext 1.0pt;padding:1.0pt 1.0pt 1.0pt 1.0pt' id=vt100><pre style='line-height:111%;background:black'><span class=od><span style='color:#BFBFBF'>print(cn.find("InterfaceDefinition").find("componentInfo").get("name")) </span></span><span style='color:#BFBFBF'><o:p></o:p></span></pre></div></td></tr></table><p class=MsoNormal><o:p> </o:p></p></div></body></html>