Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to parse xml file using XMLReader
    primarykey
    data
    text
    <p>I have a "contacts.xml" file, its structure is:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;Contacts&gt; &lt;Contact&gt; &lt;ContactId&gt;1&lt;/ContactId&gt; &lt;ContactName&gt;Aditya Kothari&lt;/ContactName&gt; &lt;MobilePhone1&gt;NA&lt;/MobilePhone1&gt; &lt;MobilePhone2&gt;NA&lt;/MobilePhone2&gt; &lt;OfficePhone1&gt;NA&lt;/OfficePhone1&gt; &lt;OfficePhone2&gt;NA&lt;/OfficePhone2&gt; &lt;OfficePhone3&gt;NA&lt;/OfficePhone3&gt; &lt;HomePhone1&gt;999-367-3944&lt;/HomePhone1&gt; &lt;HomePhone2&gt;NA&lt;/HomePhone2&gt; &lt;TokenId&gt;mtn&lt;/TokenId&gt; &lt;/Contact&gt; &lt;Contact&gt; &lt;ContactId&gt;2&lt;/ContactId&gt; &lt;ContactName&gt;Jai Mandloi &lt;/ContactName&gt; &lt;MobilePhone1&gt;NA&lt;/MobilePhone1&gt; &lt;MobilePhone2&gt;NA&lt;/MobilePhone2&gt; &lt;OfficePhone1&gt;NA&lt;/OfficePhone1&gt; &lt;OfficePhone2&gt;NA&lt;/OfficePhone2&gt; &lt;OfficePhone3&gt;NA&lt;/OfficePhone3&gt; &lt;HomePhone1&gt;800-742-9678&lt;/HomePhone1&gt; &lt;HomePhone2&gt;NA&lt;/HomePhone2&gt; &lt;TokenId&gt;mtn&lt;/TokenId&gt; &lt;/Contact&gt; &lt;/Contacts&gt; </code></pre> <p>Now i am doing this-</p> <pre><code>File xmlFile = new File("E:\\contacts.xml"); InputStream is = new FileInputStream(xmlFile); XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader reader = factory.createXMLStreamReader(is); while(reader.hasNext()) { if(reader.hasText() { System.out.println(reader.getText()); } reader.next(); } </code></pre> <p>I do not want values of "ContactId" and "TokenId" elements of xml. How should i code? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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