mirror of
https://github.com/Noratrieb/UMLetClassParser.git
synced 2026-01-15 00:55:04 +01:00
inital commit
This commit is contained in:
commit
796e786d00
6 changed files with 81 additions and 0 deletions
47
src/Main.java
Normal file
47
src/Main.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws ParserConfigurationException, IOException, SAXException {
|
||||
|
||||
String path = "C:\\Users\\nilsh\\Desktop\\Umlet/test.uxf";
|
||||
|
||||
File inputFile = new File(path);
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder builder = factory.newDocumentBuilder();
|
||||
Document doc = builder.parse(inputFile);
|
||||
System.out.println("Root element: " + doc.getDocumentElement().getNodeName());
|
||||
System.out.println("---------");
|
||||
|
||||
NodeList nList = doc.getDocumentElement().getElementsByTagName("element");
|
||||
|
||||
for (int i = 0; i < nList.getLength(); i++) {
|
||||
Node node = nList.item(i);
|
||||
System.out.println("Current Element: " + node.getNodeName());
|
||||
|
||||
if (node.getNodeType() == Node.ELEMENT_NODE){
|
||||
|
||||
Element element = (Element) node;
|
||||
|
||||
if(element.getElementsByTagName("id").item(0).getTextContent().equals("UMLClass")){
|
||||
|
||||
System.out.println("class");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue