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 6774647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:48:45+00:00 2026-05-26T15:48:45+00:00

I am just trying to insert my xml data into a table through calling

  • 0

I am just trying to insert my xml data into a table through calling a stored procedure. I doubt something is wrong in my xml and that is why I am getting the error.

My xml is bit large & here I am showing just parts of it:

<?xml version='1.0' encoding='UTF-8' ?>
<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'   xmlns:ns='http://fedex.com/ws/ship/v9' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
    <soapenv:Body>
        <ns:ProcessShipmentRequest>
            <ns:WebAuthenticationDetail>
                <ns:UserCredential>
                    <ns:Key>aaaaaa</ns:Key>
                    <ns:Password>aaaaaa</ns:Password>
                </ns:UserCredential>
            </ns:WebAuthenticationDetail>
            <ns:ClientDetail>
                <ns:AccountNumber>aaaaaa</ns:AccountNumber>
                <ns:MeterNumber>aaaaaa</ns:MeterNumber>
            </ns:ClientDetail>
            <ns:TransactionDetail>
                <ns:CustomerTransactionId>ProcessShipmentRequest_DG_HAL</ns:CustomerTransactionId>
            </ns:TransactionDetail>
            <ns:Version>
                <ns:ServiceId>ship</ns:ServiceId>
                <ns:Major>9</ns:Major>
                <ns:Intermediate>0</ns:Intermediate>
                <ns:Minor>0</ns:Minor>
            </ns:Version>
            <ns:RequestedShipment>
                <ns:ShipTimestamp>2011-11-03T06:50:40</ns:ShipTimestamp>
                <ns:DropoffType>REGULAR_PICKUP</ns:DropoffType>
                <ns:ServiceType>FEDEX_GROUND</ns:ServiceType>
                <ns:PackagingType>YOUR_PACKAGING</ns:PackagingType>
                <ns:TotalWeight>
                     <ns:Units>LB</ns:Units>
                     <ns:Value>1.0</ns:Value>
                </ns:TotalWeight>
                <ns:Shipper>
                     <ns:AccountNumber>aaaaaa</ns:AccountNumber>
                     <ns:Contact>
                          <ns:CompanyName>test</ns:CompanyName>
                          <ns:PhoneNumber>11111111</ns:PhoneNumber>
                     </ns:Contact>
                     <ns:Address>

Here is my c# code for calling the stored procedure to insert data into table

private void SaveData(string CompanyName, string Attention, string Address1, string Address2, string Country, string PostalCode, string City, string State, string Telephone, string UPSService, bool isInsured, string IdentificationNo,  string RequestXml, string ResponseXml)
{
        Database DB = GlobalObjects.GetInstance().DB;

        using (DbCommand cmd = DB.GetStoredProcCommand("InsLabelDetail"))
        {
            DB.AddInParameter(cmd, "@IdentificationNo", DbType.String, IdentificationNo);
            DB.AddInParameter(cmd, "@CompanyName", DbType.String, CompanyName);
            DB.AddInParameter(cmd, "@Attention", DbType.String, Attention);
            DB.AddInParameter(cmd, "@add1", DbType.String, Address1);
            DB.AddInParameter(cmd, "@add2", DbType.String, Address2);
            DB.AddInParameter(cmd, "@Country", DbType.String, Country);
            DB.AddInParameter(cmd, "@PostalCode", DbType.String, PostalCode);
            DB.AddInParameter(cmd, "@City", DbType.String, City);
            DB.AddInParameter(cmd, "@State", DbType.String, State);
            DB.AddInParameter(cmd, "@Telephone", DbType.String, Telephone);
            DB.AddInParameter(cmd, "@UPSService", DbType.String, UPSService);
            DB.AddInParameter(cmd, "@isInsured", DbType.Int32, (isInsured==true ? 1 : 0));
            DB.AddInParameter(cmd, "@shipto", DbType.String, Country);
            DB.AddInParameter(cmd, "@RequestXML", DbType.Xml, RequestXml.Replace("encoding='UTF-8'", string.Empty));
            DB.AddInParameter(cmd, "@ResponseXML", DbType.Xml, ResponseXml.Replace("encoding='UTF-8'", string.Empty));

            try
            {
                DB.ExecuteNonQuery(cmd);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }

The error or the exception I am getting is :

XML parsing: line 1, character 38, unable to switch the encoding

Please tell me where I made the mistake. Thanks

  • 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-05-26T15:48:45+00:00Added an answer on May 26, 2026 at 3:48 pm

    I think you have a parsing error related to UTF-8, UTF-16 encodings. That means you must show us the data that parse that xml.
    With a lucky guess, I can say that you must change the code that you read the xml data with manual encoding switching.
    For Example:

    XmlDocument _document = new XmlDocument();
    _document.LoadXml(_xmlString);
    XmlDeclaration _declaration = (XmlDeclaration)_document.FirstChild;
    _declaration.Encoding = "UTF-16";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to insert some data from a XML document into a variable table.
i'm trying to insert data into xml using php domdocument. however when i hit
I'm trying to insert into XML column (SQL SERVER 2008 R2), but the server's
I am trying to insert new lines into an Excel XML document. The entity
I am trying to insert into mysql from an xml using PHP, but the
I'm just trying to insert some variables into a DB. The connection works but
Just trying to establish whether prototype can do something like $$('#ID a:last').css('color','#111'); Any ideas
Just trying to get my head around what can happen when things go wrong
I'm trying to return rows in Open XML form from a table value function
I am trying to insert a variable into mysql from jython and am getting

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.