Welcome Guest.   Make a donation to an author on the site October 20, 2014, 07:42:38 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Check out and download the GOE 2007 Freeware Challenge productivity tools.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: C# and XML Problem - any help please?  (Read 1440 times)
Redhat
Charter Member
***
Posts: 249


View Profile WWW Give some DonationCredits to this forum member
« on: April 13, 2012, 09:51:38 PM »

Hi all  tellme

Someone's let me loose with C#.

I've nearly finished a podcast downloader application, and I'm ironing out several bugs. One of which is that I have some code that is using XmlDocument.SelectSingleNode:

Formatted for C# with the GeSHI Syntax Highlighter [copy or print]
  1. XmlNode node = doc.SelectSingleNode("rss/channel/item/title[.=\'" + episode + "\']");

Now, there is a bug when the episode variable has a colon ( : ) in it - I'd guess because it thinks I'm declaring a namespace or something.

Does anyone have a suggestion of how to escape the : character in a string please?

Many thanks!
Logged
hamradio
Charter Honorary Member
***
Posts: 588



Amateur Radio Guy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: April 13, 2012, 11:02:05 PM »

Maybe this will help (note: which is a random page I found) -> http://www.theukwebdesign...ity-escape-characters.php
Logged

Carroll - HamRadioUSA
Ath
Supporting Member
**
Posts: 2,229



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #2 on: April 14, 2012, 03:53:04 AM »

This seems helpful: http://stackoverflow.com/...-character-in-xpath-query but it's about single and double quotes mostly.

Guess you're in a deadlock, this XML spec detail seems to say you can't have a colon in an ordinary node name, but it's referring to an, obviously non-declared, namespace.
Escaping special characters is imho limited to the content part of XML, not the structure part.

You should be able to read your data though, by iterating over all the elements 1 level higher in the XML structure, and that would be /item/, right?
Logged

Redhat
Charter Member
***
Posts: 249


View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: April 14, 2012, 10:34:04 AM »

Thanks a lot for the replies ham and Ath - very useful.

I'll try iterating over the parent node - and also try deleting all colons from the XML file (apart from actual namespaces) and then reading the file with the "query term" de-coloned too smiley

I'll let you know if I'm successful.. thanks again!
Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.033s | Server load: 0.12 ]