Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>To address the specifics of doing this in netbeans (I'm using NB7.1 but it's probably pretty much the same in earlier versions), if you want to include the xml file in your netbeans project, simply create it in the source package by right-clicking the package and selecting 'New'. This will give you a list of file types. If the option for 'XML Document' is in the list then select it, otherwise select 'Other' from the list under 'New' and find it from there. From there, just fill in the details in the wizard screens.</p> <p>This will create it in your project. Bear in mind this means it will be included in the compiled .jar file, so is only useful if the file is something like fixed configuration data or a test file. For learning and testing purposes, you could always just hard-code the path of the file, but to do it correctly you can use the 'getResource' function of the class loader, something like</p> <pre><code>URL myxmlfile = yourclassname.class.getResource("/packagename/xmlfilename.xml"); </code></pre> <p>Obviously substitute your own class, package and file names in there. The path you pass to getResource is relative to the top of your project, and it returns a full name identifying where the file is, which will either be a 'file://' URL or a 'jar://' URL, depending on whether the class file gets run from within a .jar file or not. The class loader handles these details. You can then pass to the 'parse' method of the parser as was previously mentioned. You'll probably need to convert it from a URL object to a string first with 'myxmlfile.toString()'.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload