File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Help me with a regular expression to speed up the performance ??
Joined: Jun 07, 2006
Apr 04, 2011 04:27:00
I'm having XML content as a
. I'm using W3C dom for getting values from the XML.
I've a very large XML file with attributes, elements similar like below
<bookDetails bookName="How to Learn English" bookAuthor="English Writer">
<Chapter chapterName="From Alphabetes" chapterPage="23"/>
Currently I've written a method which accepts Root Element and searchable name to find the corresponding attribute or element and gets the value.
The method will get the value from a element or an attribute matching the given name.
I've used XPathAPI.selectNodeList to retrieve the value. I've used the below XPATH to check the given searchable name in both attribute and in element
xpath = "//*[@" + inAttr + "]";
xpathElement = "//" + inAttr + "/text()";
NodeList nodelist = XPathAPI.selectNodeList(root, xpath);
NodeList nodelist = XPathAPI.selectNodeList(root, xpathElement)
Sample Input and Output as follows
Output: How to Learn English
Output: test address
Input : C02 --> The element name has numeric character too
Problem: The XPATHAPI.selectNodeList() causes performance problem and it takes more time to search and gets the value.
I've planned to use regular expression (
, Matcher) to search and get the values from the XML string.
Can anyone please let me know the regular expression with a code snippet to retrieve value either from a element or an attribute
which matches the element or attribute name ???
Joined: Apr 06, 2010
Apr 04, 2011 04:29:59
Hi Kathir. Please don't post the same post to multiple forums. I think
your other post
is better placed, in the XML forum. So I'm going to lock this topic now.
I agree. Here's the link:
subject: Help me with a regular expression to speed up the performance ??
parsing data and storing in the xml
XPath expression constrained by a predicate doesn't work (//element[@attribute="value"])
how to get the whole NodeList
How to map two xml files in java
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015