Advertisement

04.03.2008 at 11:28PM PDT, ID: 23295162 | Points: 50
[x]
Attachment Details

How do i compare two xml file tags?

Am using two xml files and i want to compare those xml file tags and take the identity tags.for this am using XMLStreamReader and reading tow file tags and values..
But the thing is i cant compare the tags..
can anyone help me out this..
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
 
import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.events.XMLEvent;
 
/**
 * @author 51239
 *
 */
public class STAXCurserReadTry {
	public static int eventType;
    public static int eventType1;
    public static void main(String args[]) throws Exception {
	 try{
	    XMLInputFactory xmlif = XMLInputFactory.newInstance();
	    XMLStreamReader xmlsr = xmlif.createXMLStreamReader(new FileReader("C:/Documents and Settings/51239/Desktop/emp.xml"));
	    XMLStreamReader xmlsr1 = xmlif.createXMLStreamReader(new FileReader("C:/Documents and Settings/51239/Desktop/mapping.xml"));
	    		    
	    	while (xmlsr.hasNext()&&xmlsr1.hasNext()){
		    	eventType = xmlsr.next();
		    	eventType1 = xmlsr1.next();
		    	if(eventType==1){
		    		System.out.println(xmlsr.getName());
		    	}if(eventType==4){
		    		System.out.println(xmlsr.getText());
		    	}
		    	if(eventType1==1){
		    		System.out.println(xmlsr1.getName());
		    	}if(eventType1==4){
		    		System.out.println(xmlsr1.getText());
		    	}
		      }
    		 }catch(FactoryConfigurationError e){
			 e.printStackTrace();
	 	}
	}
}
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: jzkidding
Question Asked On: 04.03.2008
Participating Experts: 1
Points: 50
Views: 0
Translate:
Loading Advertisement...
04.07.2008 at 06:35AM PDT, ID: 21296687

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628