473,394 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

LINQ XElement.load method not working correctly with strings withperiods in them

hello all:

I am using LINQ to XML, but I think this issue is more widespread,
here's an example of what I am trying to do:

Dim testurl As String = "http://stats.enemyterritory.com/profile/
Hellfire.?xml=true"
Dim pageContents As XElement = XElement.Load(testurl)

The url in question is for a game statistics site where you can load
xml data for various players, in this case the player name has a
period
in it at the end, it's "hellfire." (another similar is "Red.")

If you take that url and plug it into a browser everything is fine,
but when I use it in the XElement Load method it drops the period, in
the case where there is a similar name without a period it returns
that page (which is the wrong one), in the case where there is no
similar name without a period it doesn't return anything.

I escaped with "%2e" and that doesn't help. Everything is fine if
there is a period in the middle of the string, it's only the one's at
the end which are an issue.

Any ideas on how to get this to work?

Thanks in advance to any who offer help.

Mike
Jun 27 '08 #1
2 4114
Mike N. wrote:
hello all:

I am using LINQ to XML, but I think this issue is more widespread,
here's an example of what I am trying to do:

Dim testurl As String = "http://stats.enemyterritory.com/profile/
Hellfire.?xml=true"
Dim pageContents As XElement = XElement.Load(testurl)

The url in question is for a game statistics site where you can load
xml data for various players, in this case the player name has a
period
in it at the end, it's "hellfire." (another similar is "Red.")

If you take that url and plug it into a browser everything is fine,
but when I use it in the XElement Load method it drops the period, in
the case where there is a similar name without a period it returns
that page (which is the wrong one), in the case where there is no
similar name without a period it doesn't return anything.

I escaped with "%2e" and that doesn't help. Everything is fine if
there is a period in the middle of the string, it's only the one's at
the end which are an issue.
This is a bug in the way .NET parses URIs. It removes the dot at the end
(possibly to work around an infamous IIS bug) but this is not legal
according to the standard, which says: "parsers must remove the dot-segments
"." and ".." when they are complete components of a path, but not when they
are only part of a segment" and gives an example of a path ending in a dot.

This is not specific to LINQ; any code path which uses the Uri class will
trigger this problem.
Any ideas on how to get this to work?
Right now, I don't.

--
J.
http://symbolsprose.blogspot.com
Jun 27 '08 #2
On Jun 2, 11:30 pm, Jeroen Mostert <jmost...@xs4all.nlwrote:
Mike N. wrote:
hello all:
I am using LINQ to XML, but I think this issue is more widespread,
here's an example of what I am trying to do:
Dim testurl As String = "http://stats.enemyterritory.com/profile/
Hellfire.?xml=true"
Dim pageContents As XElement = XElement.Load(testurl)
The url in question is for a game statistics site where you can load
xml data for various players, in this case the player name has a
period
in it at the end, it's "hellfire." (another similar is "Red.")
If you take that url and plug it into a browser everything is fine,
but when I use it in the XElement Load method it drops the period, in
the case where there is a similar name without a period it returns
that page (which is the wrong one), in the case where there is no
similar name without a period it doesn't return anything.
I escaped with "%2e" and that doesn't help. Everything is fine if
there is a period in the middle of the string, it's only the one's at
the end which are an issue.

This is a bug in the way .NET parses URIs. It removes the dot at the end
(possibly to work around an infamous IIS bug) but this is not legal
according to the standard, which says: "parsers must remove the dot-segments
"." and ".." when they are complete components of a path, but not when they
are only part of a segment" and gives an example of a path ending in a dot.

This is not specific to LINQ; any code path which uses the Uri class will
trigger this problem.
Any ideas on how to get this to work?

Right now, I don't.

--
J.http://symbolsprose.blogspot.com
That sucks, this is a pretty big deal for my app. I guess maybe I
could try and run an outside dll or something like that, maybe
something written in PHP or Perl (although I wouldn't even no where to
start with something like that).

Thanks for replying and enlightening me.

If anyone has some advice I'd really appreciate any help on this.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Marc Gravell | last post by:
In Linq, you can apparently get a meaningful body from and expression's .ToString(); random question - does anybody know if linq also includes a parser? It just seemed it might be a handy way to...
1
by: =?Utf-8?B?QWxleGFuZGVyIFd5a2Vs?= | last post by:
Thank you Wen Yuan, This did answer my question, but it took a lot of work to implement. My original code did not use any namespace so I had to modify and test some 3000 lines of code to make...
2
by: Andy B | last post by:
Hi... I have an sql server 2005 database that has a table called TestXml in it. The table has the columns ID (identity, int) and MyXml(xml). I created a stored proc on the server to insert a row...
24
by: luowan | last post by:
Hi I am currently building an application on .NetCF 3.5 in C#. The application needs to process xml files. I am thinking about using LINQ to process XML. I wrote a piece of code to modify the...
4
by: Deckarep | last post by:
Hey everyone, Is there a more elegant or cleaner way of accomplishing the following null check? List<stringmyString = null; //Purposely null list of strings to show the example XElement...
6
by: Iaml | last post by:
I have an XML file and the depth of each node is unpredictable. I need to find the parent node which contains an element whose certain attribute has the given value. Then I will process that...
2
by: timor.super | last post by:
Hi group, In my database, I have a table with fields like this : id | title | xml ------------------------------------ 1 | title1 | <datas><data><item...
4
by: CSharper | last post by:
I have following XML <root> <Person id="1"> <Name>a</Name> </Person> <Person id="2"> <Name>b</Name> </Person> </root>
5
by: Edwin | last post by:
I am trying to write an application among which one of the functions is to determine the number of unique extensions found in a directory and all of its sub directories. I am trying to use Linq to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.