Link to home
Start Free TrialLog in
Avatar of newbie27
newbie27Flag for United Kingdom of Great Britain and Northern Ireland

asked on

XML parsing: line 27, character 86, unexpected end of input

Hello Experts
I am am trying to parse the XML and save it to the database table with the field type set to XML

Is this is due to string restriction for the XML datatype?

i am using sql server 2005 and asp.net

please advise

tahnks
SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of newbie27

ASKER

Hi CodeCruiser
Thanks for picking this for me.

I was storing XML into the database table column of XML datatype, but I think becuase the XML I was reciving was not a valid XML string it was giving that error

I have changed the XML datatype to TEXT in SQL server 2005 and it works all OK now.

Thanks anyway.

I would like to close this question.

Thanks
Avatar of TMarkham1
TMarkham1

newbie27:

I don't think you found a true solution to your problem. By changing your datatype to TEXT from XML, all you managed to do was eliminate the XML parser from the mix. The database happily saves your data as TEXT now with no XML parsing.

The XML parser was telling you there is a problem with your XML. It's likely not well formed. If you are able to post your XML here, we might be able to locate and solve the real issue.
Hi TMarkham1

Thanks for your input. I think because the XML I have been sent from the third party must not be valid, I am not sure why. When I save the text as XML and view it in the browser its coming up.

The only I can see is the extra carriage returns between the codes, would this be a problem do you think?

Thanks
<?xml version="1.0" encoding="UTF-8" ?> 
<PrintTalk xmlns="http://www.printtalk.org/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.printtalk.org/schema http://www.printtalk.org/schema/printTalk_1_1.xsd" version="1.1" payloadID="1223052824.5042.49482@DDD.com" timeStamp="2009-11-13T22:35:38"> 
<Header>
<From>
    <Credential domain="Lulu">
        <Identity>Lulu</Identity> 
    </Credential>
</From>
<To>
    <Credential domain="Lulu">
        <Identity>Antony Rowe</Identity> 
    </Credential>
</To>
<Sender>
<Credential domain="Lulu">
  <Identity>Lulu</Identity> 
  <SharedSecret>G0ftR5publ0c</SharedSecret> 
</Credential>
  <UserAgent>Lulu User Agent</UserAgent> 
</Sender>
</Header>
<confirmation AgentId="GR" AgentDisplayName="GiftRepublic" RequestDate="2009-11-13T22:35:38" BusinessID="GFR123291-Confirmation" BusinessRefID="GFR123291">
<jdf:Contact ID="" Class="Parameter" Status="Available" ContactTypes="" xmlns="http://www.CIP4.org/JDFSchema_1_1">
  <Address Street="" City="" Region="" PostalCode="" CountryCode="" /> 
  <Person FirstName="" FamilyName="" /> 
  <Company ID="" Class="Parameter" Status="Available" OrganizationName="" /> 
  </jdf:Contact> 
</confirmation>   
</PrintTalk>

Open in new window

<?xml version="1.0" encoding="UTF-8" ?>

<PrintTalk xmlns="http://www.printtalk.org/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://www.printtalk.org/schema http://www.printtalk.org/schema/printTalk_1_1.xsd" version="1.1"

payloadID="1223052824.5042.49482@DDD.com" timeStamp="2009-11-13T22:35:38">

<Header>
<From>
    <Credential domain="Lulu">
        <Identity>Lulu</Identity>
    </Credential>
</From>
<To>
    <Credential domain="Lulu">
        <Identity>Antony Rowe</Identity>
    </Credential>
</To>
<Sender>
<Credential domain="Lulu">
  <Identity>Lulu</Identity>
  <SharedSecret>G0ftR5publ0c</SharedSecret>
</Credential>
  <UserAgent>Lulu User Agent</UserAgent>
</Sender>
</Header>
<confirmation AgentId="GR" AgentDisplayName="GiftRepublic" RequestDate="2009-11-13T22:35:38" BusinessID="GFR123291-Confirmation"

BusinessRefID="GFR123291">
<jdf:Contact ID="" Class="Parameter" Status="Available" ContactTypes="" xmlns="http://www.CIP4.org/JDFSchema_1_1">
  <Address Street="" City="" Region="" PostalCode="" CountryCode="" />
  <Person FirstName="" FamilyName="" />
  <Company ID="" Class="Parameter" Status="Available" OrganizationName="" />
  </jdf:Contact>

</confirmation>  

</PrintTalk>

Hi,

Please see  ID: 25830768, this is how I am getting from them. Please note the line gaps, is this route cause of this problem?

Thanks
Well, your XML does appear to be well formed... so I don't think the XML is the problem. There may be an issue with the jdk prefix on the jdk:Contact node (it doesn't look like the prefix is declared, but I doubt this is causing the  XML parsing error.

I'll run this XML into a test table myself and report back on what I see. In the meantime, check the ADO.NET portion of things. Step through the code and make sure the XML value being save to the database isn't being inadvertently cut off. This can happen if you declare the wrong datatype in SQL too. If I get it working, I'll share my code.

I'm going to object that this message is closed for now just so we can work on it and find a proper solution.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
great thank you so much for looking into this for me....

i dont really have to do anything special with the XML response I get from the client....

Its only for the record the order was successfully recieved ....

I have tried earlier with Varchar(8000) but then I was not getting the complete XML ....  because of the length perhaps...

You have not advised for using TEXT datatype any reason why please? I am currently using TEXT to save these XML files...

thank you
The TEXT datatype will work for you (for now)... but Microsoft actually recommends that people not use TEXT for new development since it is going to be deprecated in a future version of SQL Server.

By the way, varchar(max) supports up to 2,147,483,647 bytes.