Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8962757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:12:14+00:00 2026-06-15T16:12:14+00:00

I have a script to get an XML file from an SQL database. Here

  • 0

I have a script to get an XML file from an SQL database. Here is how I do this:

library(RODBC)
library(XML)

myconn <- odbcConnect("mydsn")

query.text <- "SELECT xmlfield FROM db WHERE id = 12345"
doc <- sqlQuery(myconn, query.text, stringsAsFactors=FALSE)
doc <- iconv(doc[1,1], from="latin1", to="UTF-8")
doc <- xmlInternalTreeParse(doc, encoding="UTF-8")

However, the parsing didn’t work for a particular database row, although it worked when I copied the content of this field into a separate file and parsed from the file. After two days “trial-and-error” I identified the main problem. It seems that querying short XML files this way doesn’t cause any problems, but when I query larger files, the string gets chopped off after 65534 characters. Therefore, the end of the XML file is missing and the file can’t be parsed.

I thought this might be an overall restriction of the ODBC connections on my computer. However, another programme that also uses ODBC to get the same XML field from the same database does this without any problems. So I guess it’s an R-specific problem.

Any ideas how to fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:12:15+00:00Added an answer on June 15, 2026 at 4:12 pm

    I’ve written to the package author and have finally received the following answer:

    Your inability to read is not my problem, nor is it a reasonable excuse.

    The manual says

    ‘\item[Character types] Character types can be classified three ways:
    fixed or variable length, by the maximum size and by the character
    set used. The most commonly used types\footnote{the SQL names for
    these are \code{CHARACTER VARYING} and \code{CHARACTER}, but these
    are too cumbersome for routine use.} are \code{varchar} for short
    strings of variable length (up to some maximum) and \code{char} for
    short strings of fixed length (usually right-padded with spaces).
    The value of `short’ differs by DBMS and is at least 254, often a
    few thousand—often other types will be available for longer
    character strings. There is a sanity check which will allow only
    strings of up to 65535 bytes when reading: this can be removed by
    recompiling \pkg{RODBC}.’

    This manual can be found in the doc directory of the RODBC package. This information is not contained within the reference manual.

    As in the meantime I’ve found a good solution to retrieve my data without using RODBC, I haven’t tried to recompile this package. But I hope this answer will be helpful for those having trouble with the same issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a sql database that generates an xml file. This xml file
I have a problem while reading from XML file in action script 3. This
I have a PHP script that reads in data from an XML file, returns
I have a little script here which uses DOMDocument to get my data from
I am trying to have my perl script get an Xxml file from online
I have a script that asynchronously loads image src from XML file. The sources
I have a PHP script which reads from an xml file to generate a
I have a script that loads info from external XML file and inserts it
New to jQuery, I have a script that returns data from an XML file.
I have a script that will get images from page, but how do I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.