problems in parsing the xml with the special characters

problems in parsing the xml with the special characters

Hi, I have a problem, in while parsing the xml with special characters apstrophe('). I am getting the exception Caused by: javax.xml.transform.TransformerException: misquoted literal... expected single quote!

I am passing the String adam's. when i parse this string in xml path. i am not able to fetch the adam's string in the xml.

Below is the example :

String titlepath=/InvestmentProposal/ProposedAssetAllocations/Scenarios/Scenario[IsSelected = '1']/Accounts/Account[AccountTitle='adam's']/Sleeve[IsModel='1']/AccountId/text()

method to fetch the xml: xmlManipulator.parseXPath(doc,titlePath);

here doc is nothing but the xml.

xmlManipulator.java

public class XMLManipulator {

private final Document doc;
private final XPath xpath;

public String[] parseXPath(Document doc1,String xmlPath) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException {

    int i;
    XPathExpression expr = xpath.compile(xmlPath);
    Object obj = expr.evaluate(doc1, XPathConstants.NODESET);
    NodeList nodes = (NodeList) obj;
    String[] result;
    int nodeLength = nodes.getLength();
    if (nodeLength == 0) {
        return null;
    } else {
        result = new String[nodeLength];
        for (i = 0; i < nodeLength; i++) {
            result[i] = nodes.item(i).getNodeValue();
        }
        return result;
    }
}
}

Please solve the issue that it in the xml it is searching as string adam's'.but in Xml is adam's only. How to unescape the apstophe in while passing . I tried to unescape the character (').

below is the sample one:

private String escape(String input) {

    String result = "";
    for (int i = 0; i < input.length(); i++) {
    if ("'".indexOf(input.charAt(i)) >= 0) {
    result += "\'";
    } else {
    result += input.charAt(i);

    }
    }
    return result;

    }
View Answers









Related Tutorials/Questions & Answers:
problems in parsing the xml with the special characters
problems in parsing the xml with the special characters  Hi, I have a problem, in while parsing the xml with special characters apstrophe('). I am... parse this string in xml path. i am not able to fetch the adam's string in the xml
special characters in my HTML
special characters in my HTML  How do I get special characters in my HTML
Advertisements
special characters in my HTML
special characters in my HTML  How do I get special characters in my HTML
Protect Special Characters.
Protect Special Characters.  How To Protect Special Characters in Query String
remove special characters iphone
remove special characters iphone  remove special characters iphone   Remove special characters iphone from Password NSString *outputString = [passwordString stringByReplacingOccurrencesOfString:@"%" withString
regular expression for special characters
regular expression for special characters  How to find out regular expression for special characters
replace special characters in html
replace special characters in html  How can i replace the special characters in HTML?   Special Character in HTML HTML has a long list of special characters symbol that can be used anywhere throughout the HTML Code
How to avoid the Special characters? - JDBC
How to avoid the Special characters?  I have a form in jsp... can I override special characters by submitting a form through JAVA...,   hi friend, To avoid special characters we have imposed some
How To Protect Special Characters in Query String?
How To Protect Special Characters in Query String?  How To Protect Special Characters in Query String
PHP - Match Special Characters - PHP
PHP - Match Special Characters  a PHP script that match for special character before submitting it to database
Escaping Special Characters in a Pattern
Escaping Special Characters in a Pattern   ... of detecting all special characters present in the given string. Program Result:ADS... of matching special characters in the given string or text. This program finds
Xml parsing
Xml parsing  Hi..i tried the above code but I unable to know where can i place the xml file
xml parsing
xml parsing  my task is when i wll give java file to a program that program interpret that file separate each and every keywords and indentifiers... xml.. please anyone of you give some idea
parsing xml file in jsp
parsing xml file in jsp  example that pars XML file in JSP
xml parsing - XML
± how can i do this?   Hi friend, Parsing The XML File using DOM parser in JSP visit to : http://www.roseindia.net/jsp/parsing-xml.shtml...xml parsing  Hi i want to parse the xml document which contains US en
XML parsing to Mysql database
XML parsing to Mysql database  Can someone please post the code for parsing an XML file into Mysql database using SAX
parsing xml with jquery
parsing xml with jquery  Please explain how to parse a xml file into jquery. Thanks
parsing xml using sax
parsing xml using sax  how to get values if the root elements are same and their attributes are different
xml document parsing
xml document parsing   Hi Guys, Xml document has been inserted into the database,how do i parse the xml document stored in database,so that xml document can be retrieved on to JSP file using jdbc/odbc connection. Please help me
Parsing Date Example
Parsing Date Example       This example shows how to parsing date using Format class. In this program we use a pattern of special characters to time format. Description
Truncating issue while parsing XML with SAX Parser.
Truncating issue while parsing XML with SAX Parser.  I am Parsing one xml file and after parsing I have to enter the data into the database using hibernate. The problem is while parsing some elements, its not getting the complete
XML parsing using Java - XML
XML parsing using Java  I'm trying to parse a big XML file in JAVA. The goal is like i will take console input from user until "Coverage" in element "MIRate"(THE XML code is below).once he enters coverage rate I need
parsing xml file using java code
parsing xml file using java code  parsing a xml file using java code
java with xml parsing - Java Beginners
java with xml parsing  Hi, I need the sample code for parsing complex data xml file with java code. Example product,category,subcategory these type of xml files and parse using java. Please send the code immediately its very
Problem facing in SAX Parsing - XML
Problem facing in SAX Parsing  I have facing the issue in SAX Parsing like i have got the xml and the xml structure is like below... can find the above xml there is no CountryCode in the second record and 4th
Parsing Date And Time Example
Parsing Date And Time Example       This example shows how to parsing date and time using Format class. In this program we use a pattern of special characters to time format
XML Parsing from php web server in J2ME
XML Parsing from php web server in J2ME  Hello Team, You gave some tips for XML parsing in java, i need some additional tips for xml parsing from php web server in j2me... Thanks and Regards Alagu
XML Parsing Using Sax Parser in J2ME for serverside
XML Parsing Using Sax Parser in J2ME for serverside  Hai team, i have doubt in Parsing using sax parser in serverside plz help me for xml parsing in j2me using sax parser on server side thanks in advance... regards Selva
java with xml parsing - Java Beginners
java with xml parsing  Hi, I need the sample code for parsing complex data xml file with java code. Example product,category,subcategory these type of xml files and parse using java. Please send the code immediately its very
XML Parsing Using Sax Parser in J2ME
XML Parsing Using Sax Parser in J2ME  Hai team, I hope you, You should help me, I have trouble in Xml parsing... I have decoded value, what... to do xml parsing help me for that... Regards Alagu
parsing XML file to get java object - XML
parsing XML file to get java object  Hello, I'm facing a problem in parsing XML file to get the java object. I've tried to retrieve data from XML file using SAX parser. my XML file structure is the following
complex xml parsing and storing in database - XML
complex xml parsing and storing in database  Hi Experts ,i want to parse my xml document and store it in mysql database. This is my code. How to parse this complex data. EDI_DC40 800 0000000000557748
Problem facing in SAX Parsing - XML
Problem facing in SAX Parsing  I have facing the issue in SAX Parsing like i have got the xml and the xml structure is like below... 0668420957700159USD you can find the above xml
Parsing XML using Document Builder factory - XML
Parsing XML using Document Builder factory  Hi , I am new to XML . I am trying to parse a XML file while is : For this i am using Document builder factory parser . This is required inside a STAX job.The development env
Parsing repeatitive xml elements using SAX Parser - XML
Parsing repeatitive xml elements using SAX Parser  Hi, I'm using SAX Parser to read an XML file. My XML file contains repeatitive tags. I'm able to retrieve all the values from the xml file. However, for repeatitive tags
parsing word xml file using SAX parser - XML
parsing word xml file using SAX parser  i am parsing word 2003's XML file using SAX.here my question is,i want to write some tag elements which... this xml file and write that xml part into file? can somebody
Question about parsing XML document with DOM in JAVA.
Question about parsing XML document with DOM in JAVA.  Hi, I need to parse a XML file witch has info about classes. So i have for each class to have... it with multiple for loops, one iside the other but it doesnt work. My XML is this below
How to implement xml parsing in iphone ? -RV
How to implement xml parsing in iphone ? -RV  In .h file @interface RootViewController : UITableViewController<NSXMLParserDelegate>{ IBOutlet UITableView *page1; NSMutableArray *titlearray
XML Parsing Error: mismatched tag. Expected: </br>. - JSP-Servlet
XML Parsing Error: mismatched tag. Expected: .  i had an error:"XML Parsing Error: mismatched tag. Expected: ." when uploading and writing them into an xml file. i use the jspBean to call the writeXML class. pls help me to solve
Handling Errors While Parsing an XML File
Handling Errors While Parsing an XML File   ... parsing an XML document. JAXP (Java API for XML Processing) is an interface which provides parsing of xml documents. Here the Document BuilderFactory is used
Maven Repository/Dependency: org.sonarsource.analyzer-commons | sonar-xml-parsing
Maven Repository/Dependency of Group ID org.sonarsource.analyzer-commons and Artifact ID sonar-xml-parsing. Latest version of org.sonarsource.analyzer-commons:sonar-xml-parsing dependencies. # Version Release
Java XML Parsing Using DOM
Java XML Parsing Using SAX To Parse XML document using SAX parser method you... = saxParserFactory.newSAXParser(); // Parsing XML Document by calling parse... saxParser = saxParserFactory.newSAXParser(); // Parsing XML Document
Java XML Parsing Using SAX
Java XML Parsing Using SAX To Parse XML document using SAX parser method you... = saxParserFactory.newSAXParser(); // Parsing XML Document by calling parse... saxParser = saxParserFactory.newSAXParser(); // Parsing XML Document
Maven dependency for org.sonarsource.analyzer-commons - sonar-xml-parsing version 1.28.0.1058 is released. Learn to use sonar-xml-parsing version 1.28.0.1058 in Maven based Java projects
1.28.0.1058 of sonar-xml-parsing released The developers of   org.sonarsource.analyzer-commons - sonar-xml-parsing project have released the latest...; org.sonarsource.analyzer-commons - sonar-xml-parsing library is 1.28.0.1058. Developer can
Maven dependency for org.sonarsource.analyzer-commons - sonar-xml-parsing version 1.23.0.957 is released. Learn to use sonar-xml-parsing version 1.23.0.957 in Maven based Java projects
1.23.0.957 of sonar-xml-parsing released The developers of   org.sonarsource.analyzer-commons - sonar-xml-parsing project have released the latest...; org.sonarsource.analyzer-commons - sonar-xml-parsing library is 1.23.0.957. Developer can
Maven dependency for org.sonarsource.analyzer-commons - sonar-xml-parsing version 1.24.0.965 is released. Learn to use sonar-xml-parsing version 1.24.0.965 in Maven based Java projects
1.24.0.965 of sonar-xml-parsing released The developers of   org.sonarsource.analyzer-commons - sonar-xml-parsing project have released the latest...; org.sonarsource.analyzer-commons - sonar-xml-parsing library is 1.24.0.965. Developer can
Maven dependency for org.sonarsource.analyzer-commons - sonar-xml-parsing version 1.22.0.848 is released. Learn to use sonar-xml-parsing version 1.22.0.848 in Maven based Java projects
1.22.0.848 of sonar-xml-parsing released The developers of   org.sonarsource.analyzer-commons - sonar-xml-parsing project have released the latest...; org.sonarsource.analyzer-commons - sonar-xml-parsing library is 1.22.0.848. Developer can
Maven dependency for org.sonarsource.analyzer-commons - sonar-xml-parsing version 1.27.0.1040 is released. Learn to use sonar-xml-parsing version 1.27.0.1040 in Maven based Java projects
1.27.0.1040 of sonar-xml-parsing released The developers of   org.sonarsource.analyzer-commons - sonar-xml-parsing project have released the latest...; org.sonarsource.analyzer-commons - sonar-xml-parsing library is 1.27.0.1040. Developer can
Maven dependency for org.sonarsource.analyzer-commons - sonar-xml-parsing version 1.10.1.446 is released. Learn to use sonar-xml-parsing version 1.10.1.446 in Maven based Java projects
1.10.1.446 of sonar-xml-parsing released The developers of   org.sonarsource.analyzer-commons - sonar-xml-parsing project have released the latest...; org.sonarsource.analyzer-commons - sonar-xml-parsing library is 1.10.1.446. Developer can
Maven dependency for org.sonarsource.analyzer-commons - sonar-xml-parsing version 1.21.0.829 is released. Learn to use sonar-xml-parsing version 1.21.0.829 in Maven based Java projects
1.21.0.829 of sonar-xml-parsing released The developers of   org.sonarsource.analyzer-commons - sonar-xml-parsing project have released the latest...; org.sonarsource.analyzer-commons - sonar-xml-parsing library is 1.21.0.829. Developer can

Ads