Importing multiple XML files that have varying fields - check isset() or some Java equiv?
<p>I'm importing multiple XML files that have the same tag names, but some of the files are without a few of the tags.</p>

<p>My imports work great for all files that have every "field" (ie <code>&lt;title&gt;&lt;/title&gt;</code>), but I get <code>java.lang.NullPointerException</code> when I try to set a value of my class to an item that doesn't exist in the XML file.</p>

<p>For example:</p>

<pre><code>for(NewsItem item : parser.getParsedItems())
{
    Article a1 = new Article();
    a1.title = item.title.trim();
    a1.subtitle = item.subhead.trim();
    //...
}
</code></pre>

<p>This works great for most, but if one of them doesn't have a "subhead" tag, then I get the error.</p>

<p>Is there some way I can check IF it's been set or has value prior to trying to set it to the "title" value of my Article? (as an example).</p>

<p>I tried <code>if(!item.title.isEmpty())</code> but that still gives the error.</p>

<p>(or is there a better way that I'm overlooking?)</p>
