tags:

views:

51

answers:

3

Hi,

I am writing a small test program that gives the following xml file as output:

<Books>
  <Fiction>
     <Name>Book_Name</Name>
     <Price>price in $</Price>
     <Details>hyperlink to the book's  page</Details>
  </Fiction>
</Books>

I have written this program in C# and write out this xml from LINQ. I want to add hyperlink to the book's page, so that when this xml is viewed in a browser, users can just click on the link to go the respective book's page.

I tried adding <a href="www.somepage.com">click here for details</a>, but this doesn't work. I manually added this line to xml file, I need to know whether i can do something of this sort from LINQ and hyperlink to an external webpage?

Thanks

+3  A: 

Hi,

One approach would be to use an xslt transform to change your xml block into html with links.

Enjoy!

Doug
+1  A: 

XML is not language of page layout. It doesn't define how element should be presented. HTML does, and you need to convert XML somehow so that browsers can render it to user.

Andrey
+1  A: 
<Books>
  <Fiction>
     <Name>Book_Name</Name>
     <Price>price in $</Price>
     <Details><![CDATA[<a href="www.somepage.com">click here for details</a>]]></Details>
  </Fiction>
</Books>

You can't do it because the text contains characters that are not allowed in direct element content or within attributes. You need to either escape it or use a CDATA section.

How you do this depends on how you are generating the XML.

Will