score:8
call t.tostring()
instead of value
. that will return the xml as a string. you may want to use the overload taking saveoptions to disable formatting. i can't check right now, but i suspect it will include the element tag (and elements) so you would need to strip this off.
note that if your html isn't valid xml, you will end up with an invalid overall xml file.
is the format of the xml file completely out of your control? it would be nicer for any html inside to be xml-encoded.
edit: one way of avoiding getting the outer part might be to do something like this (in a separate method called from your query, of course):
stringbuilder builder = new stringbuilder();
foreach (xnode node in element.nodes())
{
builder.append(node.tostring());
}
that way you'll get html elements with their descendants and interspersed text nodes. basically it's the equivalent of innerxml, i strongly suspect.
score:0
tiptext= t.value,
xelement.value returns only the text that is directly inside the element. text in nested elements - html or otherwise - will not be included, and of course any &-entity-references will appear in their decoded form.
if you want the content as a string with markup you could call xelement.tostring(), possibly with saveoptions.disableformatting. but note this includes the wrapping < tip> element - that is, in web browser dom terms, it's the outerhtml not the innerhtml. to get the innerhtml you would have to join together all the tostring()s of the child xelement.nodes.
score:0
just use:
string.concat(element.nodes())
to get the content with html tags.
score:1
just use string.concat(tip.nodes())
to get the content with html tags
Source: stackoverflow.com
Related Query
- Keep HTML tags in XML using LINQ to XML
- Get html tags embedded in xml using linq
- How to flatten a multi level XML into a single level XML using c# code LINQ
- Using LINQ to XML to traverse an HTML table
- I need to save the XML file using linq with xml code in C#
- Read then write html to xml file using linq xml and xml writer
- unable to persist newly added tags in xml using LINQ
- Split into xml files retaining few tags from base xml file using linq
- Construct a list of wpf Hyperlink elements from an XML source file using Linq
- Nesting XML Tags using Linq with Data From DB
- Using LINQ on XML data source
- How to Extract SVG children html tag from xml file using linq in C#
- How to load xml code block into existing xml file at a specific node using linq
- Convert string[] to int[] in one line of code using LINQ
- Empty namespace using Linq Xml
- Reading XML using XDocument & Linq - check if element is NULL?
- Update XML with C# using Linq
- How to get elements by name in XML using LINQ
- add data to existing xml file using linq
- C# check an element exists while using LINQ to XML
- How to properly search xml document using LINQ C#
- read xml file using linq
- how to add/insert conditional node into XML using linq to XML
- Compare two xml and print the difference using LINQ
- Generate xml using LINQ to XML
- Extract data from a XML string using linq vs xmlDocument
- Left outer join using LINQ -- understanding the code
- How to reuse a linq expression for 'Where' when using multiple source tables
- how to compare 2 XML using LINQ in C#
- How to read XML file using System.IO.Stream with LINQ
More Query from same tag
- How to create an UnaryExpression on Math functions as Log, Cos, Sin
- How to make calculation on time intervals?
- getting data from unbinded view and submitting form data with linq into tables
- What's wrong with this Lambda expression?
- Translating Linq Code Block into SQL
- Linq based filtering for the class based on the list values
- C# Dealing with whitespaces
- Convert or map a class instance to a list of another one by using Lambda or LINQ?
- C# How do I use a variable in a Linq select statement using Query Syntax
- Check if xml values are contained within a list
- C# - LINQ mutual exclusive elements
- LINQ query where boolean value is true or false
- Multiple filter using Linq
- Return exclusive elements from two lists that comes more than twice using linq
- how to show viewbag data in html table by converting viewbag object to list in asp.net mvc
- Possible duplicate enumeration of IEnumerable
- SQL to LINQ Statement including Group By and Order By
- CsvHelper - Split output files
- The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities. MVC User Profile Advice
- How to manually build Expression which will return always true?
- SQL Query to LINQ for MVC Controller
- Nesting LINQ to XML
- How do I get Ionide to see .net core Linq and AspNetCore namespaces?
- What is the best way to separate string using string.format() function or LINQ ?
- Select 5, 10, 15, 20 and so on with LINQ
- How can i fill Anonymous type in list?
- Using LINQ's SkipWhile over string properties
- How to bind data to DTO attribute based on a condition?
- How to implement method with expression parameter c#
- Creating ILookups