If you use an appropriate class or library, they will do the escaping for you. Many XML issues are caused by string concatenation.
XML escape characters
There are only five:
" "
' '
< <
> >
& &
Escaping characters depends on where the special character is used.
The examples can be validated at the W3C Markup Validation Service.
Text
The safe way is to escape all five characters in text. However, the three characters "
, '
and >
needn't be escaped in text:
<?xml version="1.0"?>
<valid>"'></valid>
Attributes
The safe way is to escape all five characters in attributes. However, the >
character needn't be escaped in attributes:
<?xml version="1.0"?>
<valid attribute=">"/>
The '
character needn't be escaped in attributes if the quotes are "
:
<?xml version="1.0"?>
<valid attribute="'"/>
Likewise, the "
needn't be escaped in attributes if the quotes are '
:
<?xml version="1.0"?>
<valid attribute='"'/>
Comments
All five special characters must not be escaped in comments:
<?xml version="1.0"?>
<valid>
<!-- "'<>& -->
</valid>
CDATA
All five special characters must not be escaped in CDATA sections:
<?xml version="1.0"?>
<valid>
<![CDATA["'<>&]]>
</valid>
Processing instructions
All five special characters must not be escaped in XML processing instructions:
<?xml version="1.0"?>
<?process <"'&> ?>
<valid/>
XML vs. HTML
HTML has its own set of escape codes which cover a lot more characters.
Try
var node = doc.SelectSingleNode("//*[local-name()='Cube' and @currency=\"USD\""]);
you can always add in the namespace if you know it
var node = doc.SelectSingleNode("//*[local-name()='Cube' and
namespace-uri()='http://www.ecb.int/vocabulary/2002-08-01/eurofxref' and
@currency=\"USD\""]);
Although it's longwinded I prefer it to trying to sort out namespace prefixes. And it also avoids the problem of the default namespace (xmlns="")
Best Answer
Since they both come from the same source they are both just as likely to be reliable. As for speed it would be impossible to tell and is likely to fluctuate due to environmental variables that cannot be known from your question alone.
As with all things - code the solution that is the clearest, easiest to read, and easiest to maintain. Then, if performance becomes and issue, profile your application to determine if this data feed is the source of your performance problem. Then, if you have verified that it is in fact the source of the performance problem then begin investigating ways to improve the performance.
All things being equal, I would speculate that these two data feeds would be retrieved and read by your application at similar speeds.