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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:41:41+00:00 2026-06-06T23:41:41+00:00

I want to use LINQ to insert some fields in a database. One of

  • 0

I want to use LINQ to insert some fields in a database. One of these fields contains XML data (GPX).

When I run the following code:

 rtlq.GpxData = new XElement(route.GpxData);

I get this exception:

Name cannot begin with the '<' character, hexadecimal value 0x3C

I would like to say route.GpxData has a type string and I converted this type to xml.
Here is my whole code:

public int Save(Route route)
{
    aspnetdbDataContext aspdb = new aspnetdbDataContext();
    RouteLinq rtlq=new RouteLinq();
    rtlq.UserId = route.UserId;
    rtlq.SourceName = route.Name;

    //I have an error here
    rtlq.GpxData = new XElement(route.GpxData);
    rtlq.CreationTime = route.Time;
    aspdb.RouteLinqs.InsertOnSubmit(rtlq);
    aspdb.SubmitChanges();

    int k1;
    System.Data.Linq.ChangeSet cs1 = aspdb.GetChangeSet();
    k1=cs1.Inserts.Count();

    TrackPointlinq trlq = new TrackPointlinq();
    foreach (var trackpoint in route.TrackPoints)
    {
        trlq.RouteFK=route.Id;
        trlq.TrackTime=trackpoint.Time;
        trlq.Latitude=(float) trackpoint.Latitude;
        trlq.Longitude=(float)trackpoint.Longitude;
        trlq.Elevation=trackpoint.Elevation;
    }

    aspdb.TrackPointlinqs.InsertOnSubmit(trlq);
    aspdb.SubmitChanges();

    int k2;
    System.Data.Linq.ChangeSet cs2 = aspdb.GetChangeSet();
    k2 = cs2.Inserts.Count();

    if ((k1 == 0) && (k2 == 0))
    {
        return 1;
    }
    else
        return 0;
}

Would you please help me to solve this problem?

EDIT
Sample of XML file:

<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpsies="http://www.gpsies.com/GPX/1/0" creator="GPSies http://www.gpsies.com - GpsiesTrack" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.gpsies.com/GPX/1/0 http://www.gpsies.com/gpsies.xsd">
  <metadata>
    <name>GpsiesTrack</name>
    <link href="http://www.gpsies.com/">
      <text>GpsiesTrack on GPSies.com</text>
    </link>
    <time>2012-06-26T18:58:39Z</time>
  </metadata>
  <trk>
    <name>GpsiesTrack on GPSies.com</name>
    <trkseg>
      <trkpt lat="50.81482934" lon="12.90653228">
        <ele>305.00000</ele>
        <time>2012-05-01T00:00:00Z</time>
      </trkpt>
      <trkpt lat="50.85364209" lon="12.92404174">
        <ele>297.00000</ele>
        <time>2012-05-01T00:15:27Z</time>
      </trkpt>
    </trkseg>
  </trk>
</gpx>
  • 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-06T23:41:42+00:00Added an answer on June 6, 2026 at 11:41 pm

    route.GpxData is presumably a string in XML. The XElement constructor accepting a string name will seek to convert it into an object representing an XML element. An XML element NAME cannot contain < characters, though `<‘ can be within content (if properly escaped).

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

Sidebar

Related Questions

I want to use LINQ to pass data from one custom collection to another.
I want to use Linq to extract data from an XML document and place
Some background: I have an database that I want to use linq-to-sql to update
I want to make custom select from the database table using Linq. We use
i want use some data from a website with web service. i have a
I have to insert some data periodically in my SQL Server database. But the
I want to use LINQ to convert this IEnumerable<int>[] value1ByType = new IEnumerable<int>[3]; value1ByType[0]=
this is my code that I write it but I want to use LINQ
How do you a procedure like scope identity with linq want to use it
I have some entities created with LINQ-to-SQL. Six of these entities (representing values primarily

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.