Click here to Skip to main content
15,909,822 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralConverting XML to HTML Pin
John Honan7-Apr-03 8:18
John Honan7-Apr-03 8:18 
GeneralRe: Converting XML to HTML Pin
MS le Roux8-Apr-03 1:32
MS le Roux8-Apr-03 1:32 
GeneralRe: Converting XML to HTML Pin
John Honan8-Apr-03 1:53
John Honan8-Apr-03 1:53 
GeneralMSXML 3 and escape sequences Pin
Gavin Jerman7-Apr-03 5:55
Gavin Jerman7-Apr-03 5:55 
GeneralRe: MSXML 3 and escape sequences Pin
Philip Fitzsimons8-Apr-03 3:20
Philip Fitzsimons8-Apr-03 3:20 
GeneralI have a problem with streaming XML through ASPX Pin
zoltix7-Apr-03 3:00
zoltix7-Apr-03 3:00 
GeneralRe: I have a problem with streaming XML through ASPX Pin
Philip Fitzsimons8-Apr-03 3:41
Philip Fitzsimons8-Apr-03 3:41 
QuestionHow to escape " in XPATH Expression given to SelectSingleNode() of xmldocument class Pin
Ajith Kumar6-Apr-03 18:08
Ajith Kumar6-Apr-03 18:08 
Hi all,
I have the following sample XML file
<ROOT>
<STRING id="Some string \"some with in quotes\" other\'s with apostrophee %s">
<LOCALE>Locale Equivalent of above id string</LOCALE>
<FILE line="321">myheader.h</FILE>
</STRING>
<!-- Many string tags to follow-->
<?ROOT>
The "id" contaims string constants extrcted out of C/C++ source code. and the value contains "LOCALE" contains locale equivalent string.


I load the xml document document using the XmDocument.Load( fileName) in C#.
Sample code
string idvalue = "Some string \"some with in quotes\" other\'s with apostrophee %s";
string path = "/ROOT?STRING[@id = \"" + idvalue + "\"]/LOCALE"; // so as to get the text between LOCALE tag
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
string str = doc.DocumentElement.SelectSingleNode(path).InnerXml;

Howvever the the statement throws an exception because the quotes in the path string is not escaped in XML. SelectSingleNode() takes an XPATH expression. How to escape the quotes in an XPATH expression so that the last statement works correctly.

The last expression is a problem only when their is a " in id attribute, since the attribute value is enclosed in quotes in Xpath. for id attribute values with no quotes takes me correctly to the text betwen LOCALE tag

I tried encoding the " in variable idvalue to &quot; in XPATH, still no success

The XML is successfully validated internally aginst a DTD.
The XML file contains ", ', &, <, > in their encoded form.
Any solutions to offer


Regards,
Ajith


Regards,
Ajith
GeneralXML contents for my previous question Pin
Ajith Kumar4-Apr-03 19:39
Ajith Kumar4-Apr-03 19:39 
GeneralRe: XML contents for my previous question Pin
Michael A. Barnhart5-Apr-03 0:34
Michael A. Barnhart5-Apr-03 0:34 
GeneralXML contents for my previous question Pin
Ajith Kumar4-Apr-03 19:38
Ajith Kumar4-Apr-03 19:38 
GeneralXPath Doubt Pin
Ajith Kumar4-Apr-03 19:12
Ajith Kumar4-Apr-03 19:12 
QuestionHow to do XML file modifications? Pin
Segal3-Apr-03 21:41
Segal3-Apr-03 21:41 
GeneralC# / XML attributes and values Pin
econner3-Apr-03 2:52
econner3-Apr-03 2:52 
QuestionXML parser generators? Pin
Jörgen Sigvardsson1-Apr-03 12:56
Jörgen Sigvardsson1-Apr-03 12:56 
AnswerRe: XML parser generators? Pin
Michael A. Barnhart1-Apr-03 14:40
Michael A. Barnhart1-Apr-03 14:40 
GeneralRe: XML parser generators? Pin
Jörgen Sigvardsson1-Apr-03 21:44
Jörgen Sigvardsson1-Apr-03 21:44 
GeneralRe: XML parser generators? Pin
Michael A. Barnhart2-Apr-03 0:32
Michael A. Barnhart2-Apr-03 0:32 
AnswerRe: XML parser generators? Pin
Stuart Dootson2-Apr-03 6:56
professionalStuart Dootson2-Apr-03 6:56 
GeneralRe: XML parser generators? Pin
Jörgen Sigvardsson2-Apr-03 7:42
Jörgen Sigvardsson2-Apr-03 7:42 
AnswerRe: XML parser generators? Pin
Anonymous16-Apr-03 1:55
Anonymous16-Apr-03 1:55 
QuestionIs there an "include" directive in XML? Pin
Marc Clifton29-Mar-03 4:52
mvaMarc Clifton29-Mar-03 4:52 
AnswerRe: Is there an "include" directive in XML? Pin
Michael A. Barnhart29-Mar-03 13:17
Michael A. Barnhart29-Mar-03 13:17 
AnswerRe: Is there an "include" directive in XML? Pin
Richard Deeming30-Mar-03 22:34
mveRichard Deeming30-Mar-03 22:34 
GeneralFind Element Pin
blink4me28-Mar-03 12:30
blink4me28-Mar-03 12:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.