commit 796e786d00d0e514792c17502ba033dcc5c1b9ea Author: Nilstrieb Date: Thu Nov 19 19:11:22 2020 +0100 inital commit diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..2a824a2 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..4e98f56 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/UMLClassParser.iml b/UMLClassParser.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/UMLClassParser.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..62d9fb3 --- /dev/null +++ b/src/Main.java @@ -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"); + + } + + } + } + + } + +}