S
Sanjeev
Dear Gurus
I m reading XML file in the form of string.
Below is the code.
=> XML string that pass to parseDocument(String receivedMessage) in
Parser class as follows
<?xml version="1.0" encoding="UTF-8"?>
<IFX xmlnsain001="urn:swift:xsd:$pain.001.001.01"
xmlnsain002="urn:swift:xsd:$pain.002.001.01"
xmlnsain004="urn:swift:xsd:$pain.004.001.01"
xmlns:remit="http://www.ifxforum.org/RemitDetailInfo/
2004/07"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\IFX170_XSD.xsd" >
<SignonRq>
<ClientDt>2006-02-16</ClientDt>
<CustLangPref>EN</CustLangPref>
<ClientApp>
<Org>abc</Org>
<Name>a</Name>
<Version>1</Version>
</ClientApp>
</SignonRq>
<BankSvcRq>
<RqUID>51dc8bf5-70c3-4e36-8d03-d0fb5fc58fbd</RqUID>
<XferAddRq>
<RqUID>51dc8bf5-70c3-4e36-8d03-d0fb5fc58fbd</RqUID>
<XferInfo>
<DepAcctIdFrom>
<AcctId>112</AcctId>
<AcctType/>
<AcctCur>INR</AcctCur>
<BankInfo/>
</DepAcctIdFrom>
<DepAcctIdTo>
<AcctId>54</AcctId>
<AcctType/>
<AcctCur>4</AcctCur>
<BankInfo/>
</DepAcctIdTo>
<CurAmt>
<Amt>2450</Amt>
</CurAmt>
</XferInfo>
</XferAddRq>
</BankSvcRq>
</IFX>
=> Parser which parse the above string as below
.. . . . . . .
.. . . . . . .
private void parseDocument(String receivedMessage) {
SAXParserFactory spf = SAXParserFactory.newInstance();
try {
//get a new instance of parser
SAXParser sp = spf.newSAXParser();
//parse the file and also register this class for call backs
sp.parse(new InputSource(new
ByteArrayInputStream(receivedMessage.getBytes())), this);
}catch(SAXException se) {
}catch(ParserConfigurationException pce) {
}catch (IOException ie) {
}
.. . . . . . .
.. . . . . . .
In this code I m getting error on line started with "sp.parse(new
InputSource(new ........."
Stack trace of error as below
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:
236)
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:
215)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:
386)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:
316)
at
com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:
1438)
java.lang.StringIndexOutOfBoundsException: String index out of range:
34
Could Any one help why I m getting this error..
Thanking in Advance
Regards
Sanjeev
I m reading XML file in the form of string.
Below is the code.
=> XML string that pass to parseDocument(String receivedMessage) in
Parser class as follows
<?xml version="1.0" encoding="UTF-8"?>
<IFX xmlnsain001="urn:swift:xsd:$pain.001.001.01"
xmlnsain002="urn:swift:xsd:$pain.002.001.01"
xmlnsain004="urn:swift:xsd:$pain.004.001.01"
xmlns:remit="http://www.ifxforum.org/RemitDetailInfo/
2004/07"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="C:\IFX170_XSD.xsd" >
<SignonRq>
<ClientDt>2006-02-16</ClientDt>
<CustLangPref>EN</CustLangPref>
<ClientApp>
<Org>abc</Org>
<Name>a</Name>
<Version>1</Version>
</ClientApp>
</SignonRq>
<BankSvcRq>
<RqUID>51dc8bf5-70c3-4e36-8d03-d0fb5fc58fbd</RqUID>
<XferAddRq>
<RqUID>51dc8bf5-70c3-4e36-8d03-d0fb5fc58fbd</RqUID>
<XferInfo>
<DepAcctIdFrom>
<AcctId>112</AcctId>
<AcctType/>
<AcctCur>INR</AcctCur>
<BankInfo/>
</DepAcctIdFrom>
<DepAcctIdTo>
<AcctId>54</AcctId>
<AcctType/>
<AcctCur>4</AcctCur>
<BankInfo/>
</DepAcctIdTo>
<CurAmt>
<Amt>2450</Amt>
</CurAmt>
</XferInfo>
</XferAddRq>
</BankSvcRq>
</IFX>
=> Parser which parse the above string as below
.. . . . . . .
.. . . . . . .
private void parseDocument(String receivedMessage) {
SAXParserFactory spf = SAXParserFactory.newInstance();
try {
//get a new instance of parser
SAXParser sp = spf.newSAXParser();
//parse the file and also register this class for call backs
sp.parse(new InputSource(new
ByteArrayInputStream(receivedMessage.getBytes())), this);
}catch(SAXException se) {
}catch(ParserConfigurationException pce) {
}catch (IOException ie) {
}
.. . . . . . .
.. . . . . . .
In this code I m getting error on line started with "sp.parse(new
InputSource(new ........."
Stack trace of error as below
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:
236)
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:
215)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:
386)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:
316)
at
com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:
1438)
java.lang.StringIndexOutOfBoundsException: String index out of range:
34
Could Any one help why I m getting this error..
Thanking in Advance
Regards
Sanjeev