{"id":273,"date":"2012-11-11T19:23:28","date_gmt":"2012-11-11T19:23:28","guid":{"rendered":"http:\/\/ilias-laptop\/examples\/core-java\/xml\/sax\/parse-xml-file-with-sax\/"},"modified":"2013-07-02T20:19:00","modified_gmt":"2013-07-02T17:19:00","slug":"parse-xml-file-with-sax","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/","title":{"rendered":"Parse XML file with SAX"},"content":{"rendered":"<p>With this example we are going to demonstrate how to parse an XML file with SAX. Simple API for XML (SAX) is an event-driven, serial-access mechanism for accessing XML documents. It is frequently used by servlets and network-oriented programs that need to transmit and receive XML documents, because it is the fastest and least memory-intensive mechanism that is currently available for dealing with XML documents, other than the Streaming API for XML (StAX). We have created a Class, <code>ParseXMLFileWithSAX<\/code> that is a handler that extends the <a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/org\/xml\/sax\/helpers\/DefaultHandler.html\" target=\"_blank\">DefaultHandler<\/a> and overrides its <code>startElement(String uri, String localName, String qName, Attributes attributes)<\/code> and <code>endElement(String uri, String localName, String qName)<\/code> API methods. The basic steps of the example are described below:<\/p>\n<ul>\n<li>Create a new instance of the <code>ParseXMLFileWithSAX<\/code> class.<\/li>\n<li>Obtain a new instance of a <a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/javax\/xml\/parsers\/SAXParserFactory.html\" target=\"_blank\">SAXParserFactory<\/a>, that is a factory API that enables applications to configure and obtain a SAX based parser to parse XML documents.<\/li>\n<li>Set the parser produced by this code so as not to validate documents as they are parsed, using <code>setValidating(boolean validating)<\/code> API method of SAXParserFactory with validating set to false.<\/li>\n<li>Create a new instance of a <a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/javax\/xml\/parsers\/SAXParser.html\" target=\"_blank\">SAXParser<\/a>, using <code>newSAXParser()<\/code> API method of SAXParserFactory. <\/li>\n<li>Use <code>parse(File f, DefaultHandler dh)<\/code> API method of SAXParser to parse the content of the specified XML file, using the specified handler of the example.<\/li>\n<li>The <code>ParseXMLFileWithSAX<\/code> class of the example overrides <code>startElement(String uri, String localName, String qName, Attributes attributes)<\/code> and <code>endElement(String uri, String localName, String qName)<\/code> API methods of DefaultHandler. For example it can append to a buffer the attributes of the Element and when it reaches to the end of the element it can print the results.<\/li>\n<\/ul>\n<p>Let\u2019s take a look at the code snippet that follows:  <div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:java\">\r\npackage com.javacodegeeks.snippets.core;\r\n\r\nimport java.io.File;\r\nimport java.util.LinkedList;\r\nimport java.util.List;\r\n\r\nimport javax.xml.parsers.SAXParser;\r\nimport javax.xml.parsers.SAXParserFactory;\r\n\r\nimport org.xml.sax.Attributes;\r\nimport org.xml.sax.SAXException;\r\nimport org.xml.sax.helpers.DefaultHandler;\r\n\r\npublic class ParseXMLFileWithSAX extends DefaultHandler {\r\n\t\r\nprivate StringBuffer buffer = new StringBuffer();\r\n\t\r\n\tprivate static String responseCode;\r\n\tprivate static String date;\r\n\tprivate static String title;\r\n\t\r\n\tprivate static Currency currency;\r\n\tprivate static Rates rates;\r\n\t\r\n\tpublic static void main(String[] args) throws Exception {\r\n\t\t\r\n\t\tDefaultHandler handler = new ParseXMLFileWithSAX();\r\n\r\n\t\tSAXParserFactory factory = SAXParserFactory.newInstance();\r\n\r\n  factory.setValidating(false);\r\n\r\n  \r\n\r\n  SAXParser parser = factory.newSAXParser();\r\n\r\n  \r\n\r\n  parser.parse(new File(\"in.xml\"), handler);\r\n\r\n  \r\n\r\n  System.out.println(\"Response Code:\" + responseCode);\r\n\r\n  System.out.println(\"Date:\" + date);\r\n\r\n  System.out.println(\"Title:\" + title);\r\n\r\n  System.out.println(\"Rates:\");\r\n\r\n  \r\n\r\n  for (Currency curr : rates.currencies) {\r\n\t\t\tSystem.out.println(\"tCode:\" + curr.code + \" - Rate:\" + curr.rate);\r\n\t\t}\r\n\t\t\r\n\t}\r\n\t\r\n\tprivate static class Currency {\r\n\t\tpublic String code;\r\n\t\tpublic String rate;\r\n\t}\r\n\t\r\n\tprivate static class Rates {\r\n\t\tpublic List&lt;Currency&gt; currencies = new LinkedList&lt;Currency&gt;();\r\n\t}\r\n\t\r\n\t@Override\r\n\tpublic void startElement(String uri, String localName, String qName,\r\n\t\t\tAttributes attributes) throws SAXException {\r\n\t\t\r\n\t\tbuffer.setLength(0);\r\n\t\t\r\n\t\tif (qName.equals(\"response\")) {\r\n\t\t\tresponseCode = attributes.getValue(\"code\");\r\n\t\t}\r\n\t\telse if (qName.equals(\"date\")) {\r\n\t\t\tdate = \"\";\r\n\t\t}\r\n\t\telse if (qName.equals(\"title\")) {\r\n\t\t\ttitle = \"\";\r\n\t\t}\r\n\t\telse if (qName.equals(\"rates\")) {\r\n\t\t\trates = new Rates(); \r\n\t\t}\r\n\t\telse if (qName.equals(\"currency\")) {\r\n\t\t\tcurrency = new Currency(); \r\n\t\t}\r\n\t\t\r\n\t}\r\n\t\r\n\t@Override\r\n\tpublic void endElement(String uri, String localName, String qName)throws SAXException {\r\n\t\t\r\n\t\tif (qName.equals(\"date\")) {\r\n\t\t\tdate = buffer.toString();\r\n\t\t}\r\n\t\telse if (qName.equals(\"title\")) {\r\n\t\t\ttitle = buffer.toString();\r\n\t\t}\r\n\t\telse if (qName.equals(\"currency\")) {\r\n\t\t\trates.currencies.add(currency);\r\n\t\t}\r\n\t\telse if (qName.equals(\"code\")) {\r\n\t\t\tcurrency.code = buffer.toString();\r\n\t\t}\r\n\t\telse if (qName.equals(\"rate\")) {\r\n\t\t\tcurrency.rate = buffer.toString();\r\n\t\t}\r\n\t\t\r\n\t}\r\n\t\r\n    public void characters(char[] ch, int start, int length) {\r\n\t\tbuffer.append(ch, start, length);\r\n\t}\r\n\r\n}\r\n<\/pre>\n<p>\n<b>Input:<\/b><\/p>\n<pre class=\"brush:xml\">\r\n&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt;\r\n&lt;response code=\"200\"&gt;\r\n\t&lt;date&gt;2008-11-07&lt;\/date&gt;\r\n\t&lt;title&gt;Exchange rates for 2008-11-07&lt;\/title&gt;\r\n\t&lt;rates&gt;\r\n\t\t&lt;currency&gt;\r\n\t\t\t&lt;code&gt;EUR&lt;\/code&gt;\r\n\t\t\t&lt;rate&gt;1.220&lt;\/rate&gt;\r\n\t\t&lt;\/currency&gt;\r\n\t\t&lt;currency&gt;\r\n\t\t\t&lt;code&gt;USD&lt;\/code&gt;\r\n\t\t\t&lt;rate&gt;1.275&lt;\/rate&gt;\r\n\t\t&lt;\/currency&gt;\r\n\t&lt;\/rates&gt;\r\n&lt;\/response&gt;\r\n<\/pre>\n<p>\n<b>Output:<\/b><\/p>\n<pre style=\"background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 0px; text-align: left; width: 99%;\">\r\n<code style=\"color: black; word-wrap: normal;\">Response Code:200\r\nDate:2008-11-07\r\nTitle:Exchange rates for 2008-11-07\r\nRates:\r\n\tCode:EUR - Rate:1.0\r\n\tCode:USD - Rate:1.275600<\/code>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>With this example we are going to demonstrate how to parse an XML file with SAX. Simple API for XML (SAX) is an event-driven, serial-access mechanism for accessing XML documents. It is frequently used by servlets and network-oriented programs that need to transmit and receive XML documents, because it is the fastest and least memory-intensive &hellip;<\/p>\n","protected":false},"author":6,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[163],"tags":[189,234,1066],"class_list":["post-273","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sax","tag-core-java-2","tag-sax-2","tag-xml"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Parse XML file with SAX - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"With this example we are going to demonstrate how to parse an XML file with SAX. Simple API for XML (SAX) is an event-driven, serial-access mechanism for\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Parse XML file with SAX - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"With this example we are going to demonstrate how to parse an XML file with SAX. Simple API for XML (SAX) is an event-driven, serial-access mechanism for\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-11T19:23:28+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-07-02T17:19:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Byron Kiourtzoglou\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Byron Kiourtzoglou\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/\"},\"author\":{\"name\":\"Byron Kiourtzoglou\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3b111ec1048740c68c9e709ff6240015\"},\"headline\":\"Parse XML file with SAX\",\"datePublished\":\"2012-11-11T19:23:28+00:00\",\"dateModified\":\"2013-07-02T17:19:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/\"},\"wordCount\":252,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"core java\",\"sax\",\"xml\"],\"articleSection\":[\"SAX\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/\",\"name\":\"Parse XML file with SAX - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2012-11-11T19:23:28+00:00\",\"dateModified\":\"2013-07-02T17:19:00+00:00\",\"description\":\"With this example we are going to demonstrate how to parse an XML file with SAX. Simple API for XML (SAX) is an event-driven, serial-access mechanism for\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"xml\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"SAX\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/sax\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"Parse XML file with SAX\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3b111ec1048740c68c9e709ff6240015\",\"name\":\"Byron Kiourtzoglou\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Byron-Kiourtzoglou-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Byron-Kiourtzoglou-96x96.jpg\",\"caption\":\"Byron Kiourtzoglou\"},\"description\":\"Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications\/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.\",\"sameAs\":[\"https:\/\/www.pivotalgamers.com\/\",\"https:\/\/www.linkedin.com\/in\/byron-kiourtzoglou-530ab222\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/byron-kiourtzoglou\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Parse XML file with SAX - Java Code Geeks","description":"With this example we are going to demonstrate how to parse an XML file with SAX. Simple API for XML (SAX) is an event-driven, serial-access mechanism for","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/","og_locale":"en_US","og_type":"article","og_title":"Parse XML file with SAX - Java Code Geeks","og_description":"With this example we are going to demonstrate how to parse an XML file with SAX. Simple API for XML (SAX) is an event-driven, serial-access mechanism for","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-11-11T19:23:28+00:00","article_modified_time":"2013-07-02T17:19:00+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Byron Kiourtzoglou","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Byron Kiourtzoglou","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/"},"author":{"name":"Byron Kiourtzoglou","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3b111ec1048740c68c9e709ff6240015"},"headline":"Parse XML file with SAX","datePublished":"2012-11-11T19:23:28+00:00","dateModified":"2013-07-02T17:19:00+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/"},"wordCount":252,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["core java","sax","xml"],"articleSection":["SAX"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/","name":"Parse XML file with SAX - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2012-11-11T19:23:28+00:00","dateModified":"2013-07-02T17:19:00+00:00","description":"With this example we are going to demonstrate how to parse an XML file with SAX. Simple API for XML (SAX) is an event-driven, serial-access mechanism for","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/sax\/parse-xml-file-with-sax\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"xml","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/"},{"@type":"ListItem","position":5,"name":"SAX","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/sax\/"},{"@type":"ListItem","position":6,"name":"Parse XML file with SAX"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/3b111ec1048740c68c9e709ff6240015","name":"Byron Kiourtzoglou","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Byron-Kiourtzoglou-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/10\/Byron-Kiourtzoglou-96x96.jpg","caption":"Byron Kiourtzoglou"},"description":"Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications\/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.","sameAs":["https:\/\/www.pivotalgamers.com\/","https:\/\/www.linkedin.com\/in\/byron-kiourtzoglou-530ab222"],"url":"https:\/\/examples.javacodegeeks.com\/author\/byron-kiourtzoglou\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=273"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/273\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}