title: Example with PyXB: Generate Python code and obtain Attribute value within XML Element
body: <p>I am having a hard time getting started with PyXB. </p>
  
  <p>Let's use this XML file for example:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;purchaseOrder orderDate="1999-10-20"&gt;
    &lt;shipTo country="US"&gt;
      &lt;name&gt;Alice Smith&lt;/name&gt;
      &lt;street&gt;123 Maple Street&lt;/street&gt;
      &lt;city&gt;Anytown&lt;/city&gt;&lt;state&gt;AK&lt;/state&gt;&lt;zip&gt;12341&lt;/zip&gt;
    &lt;/shipTo&gt;
    &lt;billTo country="US"&gt;
      &lt;name&gt;Robert Smith&lt;/name&gt;
      &lt;street&gt;8 Oak Avenue&lt;/street&gt;
      &lt;city&gt;Anytown&lt;/city&gt;&lt;state&gt;AK&lt;/state&gt;&lt;zip&gt;12341&lt;/zip&gt;
    &lt;/billTo&gt;
  &lt;/purchaseOrder&gt;
  </code></pre>
  
  <p>Say if I managed to create the Python library pol.py:</p>
  
  <p><strong>Python code</strong></p>
  
  <pre><code>import po1
  xml = open('po1.xml').read()
  order = po1.CreateFromDocument(xml)
  </code></pre>
  
  <p>I understand that I can obtain content within Element (eg. order.billTo.name = Robert Smith), but how do I obtain the value from Attribute "country" (which is "US")? </p>
  
  <p>Thanks in advance!</p>
  
  <p>Reference:
  <a href="http://pyxb.sourceforge.net/userref_pyxbgen.html" rel="nofollow">http://pyxb.sourceforge.net/userref_pyxbgen.html</a></p>