Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

JAVA XML COURSE

import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.io.*;
Comment

JAVA XML COURSE

DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Comment

JAVA XML COURSE

StringBuilder xmlStringBuilder = new StringBuilder();
xmlStringBuilder.append("<?xml version="1.0"?> <class> </class>");
ByteArrayInputStream input = new ByteArrayInputStream(
   xmlStringBuilder.toString().getBytes("UTF-8"));
Document doc = builder.parse(input);
Comment

JAVA XML COURSE

Element root = document.getDocumentElement();
Comment

JAVA XML COURSE

//returns specific attribute
getAttribute("attributeName");

//returns a Map (table) of names/values
getAttributes();
Comment

JAVA XML COURSE

//returns a list of subelements of specified name
getElementsByTagName("subelementName");

//returns a list of all child nodes
getChildNodes();
Comment

JAVA XML COURSE

<?xml version = "1.0"?>
<class>
   <student rollno = "393">
      <firstname>dinkar</firstname>
      <lastname>kad</lastname>
      <nickname>dinkar</nickname>
      <marks>85</marks>
   </student>
   
   <student rollno = "493">
      <firstname>Vaneet</firstname>
      <lastname>Gupta</lastname>
      <nickname>vinni</nickname>
      <marks>95</marks>
   </student>
   
   <student rollno = "593">
      <firstname>jasvir</firstname>
      <lastname>singn</lastname>
      <nickname>jazz</nickname>
      <marks>90</marks>
   </student>
</class>
Comment

PREVIOUS NEXT
Code Example
Java :: android autocompletetextview hashmap 
Java :: Change or Replace ArrayList Elements using set() function 
Java :: session-less control using java 
Java :: spring security not going to logout success urk 
Java :: null pointer exception during registering user to the firebase 
Java :: java.lang.NullPointerException at org.openqa.selenium.support.pagefactory.findElement(DefaultElementLocator.java:69) 
Java :: arraylist how to add at 0 java 
Java :: Rotate Left k cells java 
Java :: arraylist character agregar elementos en java 
Java :: Second Activity not opening problem 
Java :: Bukkit dev paid account 
Java :: try catch still prints java 
Java :: reset status bar color in android 
Java :: import claim jwt 
Java :: java output formatting 
Java :: java logger errorAdd Answer 
Java :: convert xml file to node tree with java 
Java :: Reason: Failed to load driver class com.mysql.cj.jdbc.Driver in either of HikariConfig class loader or Thread context classloader 
Java :: concludes() Method 
Java :: nullpointerexception 
Java :: Duplicate class com.google.android.gms.internal.firebase_messaging.zzo found in modules jetified-firebase-iid 
Java :: java break statement 
Java :: java android join array list 
Java :: alert dialog not displayed android 
Java :: lombok 
Java :: void setup 
Java :: style jbuttons 
Java :: how to get history stack in android webview 
Sql :: sql server search column name in all tables 
Sql :: set password for postgres user ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =