{"id":20690,"date":"2015-03-17T15:00:38","date_gmt":"2015-03-17T13:00:38","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=20690"},"modified":"2015-03-17T11:41:12","modified_gmt":"2015-03-17T09:41:12","slug":"xpath-substring-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/","title":{"rendered":"XPath substring example"},"content":{"rendered":"<p>In this example, we will try to see how we can use the <code>sub-string<\/code> method in the <code>XPath<\/code> for our use-cases.<\/p>\n<p>The <code>sub-string<\/code> method is used to search for the sub-string in the beginning or the end or anywhere in the <code>XPath<\/code> node. It can also be used to extract the part of the sub-string from the string by specifying the beginning index and end index.<\/p>\n<p>&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<p>The <code>XPath<\/code> provides following methods for this :<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li><code>substring-before(String target, String tosearch)<\/code><\/li>\n<li><code>substring-after(String target, String tosearch)<\/code><\/li>\n<li><code>substring(String target, int startingindex, int length)<\/code><\/li>\n<\/ul>\n<p>We will look at all the methods in brief and see how to use each of them. <\/p>\n<p><span style=\"text-decoration: underline\"> <em>cricketTeam_info.java:<\/em><\/span><\/p>\n<pre class=\"brush:xml\">\r\n\r\n&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n\r\n&lt;cricketers&gt;\r\n\t&lt;cricketer type=\"righty\"&gt;\r\n\t\t&lt;name&gt;MS Dhoni&lt;\/name&gt;\r\n\t\t&lt;role&gt;Captain&lt;\/role&gt;\r\n\t\t&lt;position&gt;Wicket-Keeper&lt;\/position&gt;\r\n\t&lt;\/cricketer&gt;\r\n\t&lt;cricketer type=\"lefty\"&gt;\r\n\t\t&lt;name&gt;Shikhar Dhawan&lt;\/name&gt;\r\n\t\t&lt;role&gt;Batsman&lt;\/role&gt;\r\n\t\t&lt;position&gt;Point&lt;\/position&gt;\r\n\t&lt;\/cricketer&gt;\r\n\t&lt;cricketer type=\"righty\"&gt;\r\n\t\t&lt;name&gt;Virat Kohli&lt;\/name&gt;\r\n\t\t&lt;role&gt;Batsman&lt;\/role&gt;\r\n\t\t&lt;position&gt;cover&lt;\/position&gt;\r\n\t&lt;\/cricketer&gt;\r\n\t&lt;cricketer type=\"righty\"&gt;\r\n\t\t&lt;name&gt;Shami&lt;\/name&gt;\r\n\t\t&lt;role&gt;Bowler&lt;\/role&gt;\r\n\t\t&lt;position&gt;SquareLeg&lt;\/position&gt;\r\n\t&lt;\/cricketer&gt;\r\n\t&lt;cricketer type=\"lefty\"&gt;\r\n\t\t&lt;name&gt;Zaheer Khan&lt;\/name&gt;\r\n\t\t&lt;role&gt;Bowler&lt;\/role&gt;\r\n\t\t&lt;position&gt;FineLeg&lt;\/position&gt;\r\n\t&lt;\/cricketer&gt;\r\n&lt;\/cricketers&gt;\r\n\r\n<\/pre>\n<h2>1. substring(String target, int startingindex, int length)<\/h2>\n<p><code>Substring(target, startindex, length, )<\/code> method returns the sub-string of the target string from the start-index to the <code>length<\/code> specified. If the length argument is not provided, it returns the string from the <code>start-index<\/code> specified to the last character of the target string.<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\n\r\nXPathExpression expr = xpath.compile(\"substring(\/\/cricketer[name='MS Dhoni']\/position,'1','4')\");\r\nString substr = (String) expr.evaluate(doc, XPathConstants.STRING);\r\nSystem.out.println(\"The substring of Wicket is : \" + substr );\r\n\r\n<\/pre>\n<p><span style=\"text-decoration: underline\"><em>Output:<\/em><\/span><\/p>\n<pre class=\"brush:bash\">\r\n\r\nThe substring  of Wicket is : Wick\r\n\r\n<\/pre>\n<p>The target string here is &#8216;<em>wicket-keeper<\/em>&#8216;. By passing <code>1,4<\/code> we are extracting the characters from 1st to 4th position of the target string.<\/p>\n<div class=\"tip\"><strong>NOTE:<\/strong><br \/> Unlike in Java, the XPath string index starts with 1.<\/div>\n<h2>2. substring-before(String target, String tosearch)<\/h2>\n<p>The <code>substring-before<\/code> is used to extract the substring of the target occurring before an occurrence of the string passed as toSearch argument. Lets look at an example to understand this :<\/p>\n<pre class=\"brush:java\">\r\n\r\nexpr = xpath.compile(\"substring-before(\/\/cricketer[name='MS Dhoni']\/position,'-Keeper')\");\r\nString substrbefore = (String) expr.evaluate(doc, XPathConstants.STRING);\r\nSystem.out.println(\"The substring before Keeper is : \" + substrbefore);\r\n\r\n<\/pre>\n<p><span style=\"text-decoration: underline\"><em>Output:<\/em><\/span><\/p>\n<pre class=\"brush:bash\">\r\n\r\nThe substring before Keeper is : Wicket\r\n\r\n<\/pre>\n<p>The string occurring prior to <em>&#8220;-Keeper&#8221;<\/em> in <em>&#8220;Wicket-Keeper&#8221;<\/em> is returned by the <code>substring-before <\/code>method.<\/p>\n<h2>3. substring-after(String target, String tosearch)<\/h2>\n<p>This method works exactly opposite of the <code>substring-before<\/code> method. It returns the substring after the tosearch string till the end of the target string.<\/p>\n<pre class=\"brush:java\">\r\nexpr = xpath.compile(\"substring-after(\/\/cricketer[name='MS Dhoni']\/position,'Wicket-')\");\r\nString substrafter = (String) expr.evaluate(doc, XPathConstants.STRING);\r\nSystem.out.println(\"The substring after Keeper is : \" + substrafter);\r\n\r\n<\/pre>\n<p><span style=\"text-decoration: underline\"><em>Output:<\/em><\/span><\/p>\n<pre class=\"brush:bash\">\r\n\r\nThe substring after Keeper is : Keeper\r\n\r\n<\/pre>\n<p>The <code>substring-after<\/code> returns the substring after the &#8220;<em>Wicket<\/em>&#8220;, which is &#8220;<em>keeper<\/em>&#8220;.<\/p>\n<p><span style=\"text-decoration: underline\"> <em>XpathSubStringDemo.java:<\/em><\/span><\/p>\n<pre class=\"brush:java\">\r\n\r\nimport javax.xml.parsers.DocumentBuilder;\r\nimport javax.xml.parsers.DocumentBuilderFactory;\r\nimport javax.xml.xpath.XPath;\r\nimport javax.xml.xpath.XPathConstants;\r\nimport javax.xml.xpath.XPathExpression;\r\nimport javax.xml.xpath.XPathFactory;\r\n\r\nimport org.w3c.dom.Document;\r\n\r\n\r\npublic class XpathSubStringDemo\r\n{\r\n\tpublic static void main(String[] args) throws Exception\r\n\t{\r\n\r\n\t\tDocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();\r\n\t\tdocumentBuilderFactory.setNamespaceAware(true);\r\n\t\tDocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();\r\n\t\tDocument doc = documentBuilder.parse(\"src\/cricketTeam_info.xml\");\r\n\r\n\t\tXPathFactory xpathFactory = XPathFactory.newInstance();\r\n\t\tXPath xpath = xpathFactory.newXPath();\r\n\r\n\t\t\/\/XPath subtring example\r\n\t\tXPathExpression expr = xpath.compile(\"substring(\/\/cricketer[name='MS Dhoni']\/position,'1','4')\");\r\n\t\tString substr = (String) expr.evaluate(doc, XPathConstants.STRING);\r\n\t\tSystem.out.println(\"The substring before Keeper is : \" + substr);\r\n\r\n\t\t\/\/ XPath subtring-before example\r\n\t\texpr = xpath.compile(\"substring-before(\/\/cricketer[name='MS Dhoni']\/position,'-Keeper')\");\r\n\t\tString substrbefore = (String) expr.evaluate(doc, XPathConstants.STRING);\r\n\t\tSystem.out.println(\"The substring before Keeper is : \" + substrbefore);\r\n\r\n\r\n\t\t\/\/ XPath subtring-after example\r\n\t\texpr = xpath.compile(\"substring-after(\/\/cricketer[name='MS Dhoni']\/position,'Wicket-')\");\r\n\t\tString substrafter = (String) expr.evaluate(doc, XPathConstants.STRING);\r\n\t\tSystem.out.println(\"The substring after Keeper is : \" + substrafter);\r\n\r\n\r\n\t}\r\n}\r\n\r\n<\/pre>\n<h2>4. Conclusion: <\/h2>\n<p>Here we studied the sub-string method and how to use them.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/> You can download the source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/XpathSubstringDemo.zip\" rel=\"external nofollow\" title=\"\" class=\"ext-link\"><strong>XpathSubStringDemo.zip<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example, we will try to see how we can use the sub-string method in the XPath for our use-cases. The sub-string method is used to search for the sub-string in the beginning or the end or anywhere in the XPath node. It can also be used to extract the part of the sub-string &hellip;<\/p>\n","protected":false},"author":30,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[],"class_list":["post-20690","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-xpath"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>XPath substring example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this example, we will try to see how we can use the sub-string method in the XPath for our use-cases. The sub-string method is used to search for the\" \/>\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\/xpath\/xpath-substring-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"XPath substring example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this example, we will try to see how we can use the sub-string method in the XPath for our use-cases. The sub-string method is used to search for the\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/\" \/>\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=\"2015-03-17T13:00:38+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=\"Chandan Singh\" \/>\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=\"Chandan Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 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\/xpath\/xpath-substring-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/\"},\"author\":{\"name\":\"Chandan Singh\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/86537f90d4f34206febe90a0fbd6cd33\"},\"headline\":\"XPath substring example\",\"datePublished\":\"2015-03-17T13:00:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/\"},\"wordCount\":287,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"articleSection\":[\"XPath\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/\",\"name\":\"XPath substring example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2015-03-17T13:00:38+00:00\",\"description\":\"In this example, we will try to see how we can use the sub-string method in the XPath for our use-cases. The sub-string method is used to search for the\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#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\/xpath\/xpath-substring-example\/#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\":\"XPath\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/xpath\/\"},{\"@type\":\"ListItem\",\"position\":6,\"name\":\"XPath substring example\"}]},{\"@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\/86537f90d4f34206febe90a0fbd6cd33\",\"name\":\"Chandan Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/Chandan-Singh-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/Chandan-Singh-96x96.jpg\",\"caption\":\"Chandan Singh\"},\"description\":\"Chandan holds a degree in Computer Engineering and is a passionate software programmer. He has good experience in Java\/J2EE Web-Application development for Banking and E-Commerce Domains.\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/chandan-singh\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"XPath substring example - Java Code Geeks","description":"In this example, we will try to see how we can use the sub-string method in the XPath for our use-cases. The sub-string method is used to search for the","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\/xpath\/xpath-substring-example\/","og_locale":"en_US","og_type":"article","og_title":"XPath substring example - Java Code Geeks","og_description":"In this example, we will try to see how we can use the sub-string method in the XPath for our use-cases. The sub-string method is used to search for the","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2015-03-17T13:00:38+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":"Chandan Singh","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Chandan Singh","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/"},"author":{"name":"Chandan Singh","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/86537f90d4f34206febe90a0fbd6cd33"},"headline":"XPath substring example","datePublished":"2015-03-17T13:00:38+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/"},"wordCount":287,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","articleSection":["XPath"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/","name":"XPath substring example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2015-03-17T13:00:38+00:00","description":"In this example, we will try to see how we can use the sub-string method in the XPath for our use-cases. The sub-string method is used to search for the","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/xml\/xpath\/xpath-substring-example\/#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\/xpath\/xpath-substring-example\/#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":"XPath","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/xml\/xpath\/"},{"@type":"ListItem","position":6,"name":"XPath substring example"}]},{"@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\/86537f90d4f34206febe90a0fbd6cd33","name":"Chandan Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/Chandan-Singh-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/10\/Chandan-Singh-96x96.jpg","caption":"Chandan Singh"},"description":"Chandan holds a degree in Computer Engineering and is a passionate software programmer. He has good experience in Java\/J2EE Web-Application development for Banking and E-Commerce Domains.","sameAs":["http:\/\/www.javacodegeeks.com\/"],"url":"https:\/\/examples.javacodegeeks.com\/author\/chandan-singh\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/20690","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\/30"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=20690"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/20690\/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=20690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=20690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=20690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}