We help IT Professionals succeed at work.

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

newbie27
newbie27 asked
on
5,046 Views
Last Modified: 2012-08-13
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
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
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
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.

Author

Commented:
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

Author

Commented:
<?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>

Author

Commented:
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.
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
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.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.