I am using LINQ-to-XML. I am building a small program that helps parse HTML. I'd like to save the HTML tags into an XML file, but I don't want the XML file to check the validity of the entered HTML elements.
How can I just entere a simple string literal (a pretty long one)?
Maybe using a CDATA construct could help you out, see w3schools.com
Related
Classic problem. Want to see html rendered but I'm seeing text in the browser. Whether I tell handlebars js to decode it or not in template ( three curly braces vs two - {{{myHtmlData}}} vs {{myHtmlData}} ) doesn't get me there. Something about the JSON being returned via the model.fetch() has this html data wrapped up in such a way that it is resistant to the notion of displaying as HTML. It's always considered a string whether encoded or decoded so it always displays as text.
Is this just something backbone isn't meant to do?
The technologies involved here are:
backbone.marionette
handlebars.js
.NET Web API
Your data is being escaped automatically. It's a good thing, but since you're sure the data is a safe HTML. Use {{{}}} as in this other question Insert html in a handlebar template without escaping .
I have an app that builds XML, the text nodes values are coming from the users.
How would I HTML encode that input to avoid bad characters?
Preferably looking for a built in solution in Action Script.
I've used escape() and unescape() for POST variables in the past, not sure if it's the best solution for XML though.
This method seems promising: http://www.markledford.com/blog/2009/02/25/as3-htmldecode-htmlencode-xml-hack/
You can also try converting the string to a textnode as mentioned in How do you encode XML safely with ActionScript 3?
i am trying to code XSLT and xml..
one of the problem i am facing is i actually get the values of my xslt file from the xml file one of the fields like description have html tags
<span class="text"><xsl:value-of select=BusinessDescription" >
</xsl:value-of></span><br />
so its outputting including the html tags like
<p> Hello there,</P>
<b>Hotel</b>
how do i transform the html on the web browser to show the output of the html tags??
like
Hello there,
Hotel
If I understand this question well, you are asking how to interprete escaped markup not as text but as markup.
The answer is:
This cannot be done in pure XSLT 1.0 or XSLT 2.0 (in XSLT 3.0 / XPath 3.0 there might be a function to parse a string as XML).
To do this you need to write an extension function, that takes a string, parses this as XML document and returns the resulting XML document.
Therefore, instead of:
<xsl:value-of select="BusinessDescription"/>
the code that uses this extension function would look something like this:
<xsl:copy-of select="my:xml-parse(BusinessDescription)"/>
The extension function itself would be written in your favourite PL and will simply create an XmlDocument object and try to load the string (with a method such as LoadXml()), then return this XmlDocument as its result.
If you could post the XSL and XML (try to reduce them to the smallest code that still produces the problem) we could give a more accurate answer. One likely possibility is that your XSL does not produce the <html><body>...</body></html> tags.
Your HTML content should enclosed inside the <body>...</body> element.
Has anyone run into the XML parser just ending when it encounters HTML entities like Ã?
Thanks
Deshawn
Yes, this problem is because the the XMLParser is using element validation, which will break if it sees an html element like the one you described. If you want to parse HTML you will want to use Hpple.
Check out this post for more information.
parsing HTML on the iPhone
Im trying to generate a xml from a html (url). The html website have a formulary that i want to get into a xml archive, but its too long and im searching a way to do it easier.
There is a method to generate a xml with all the fields, etc, from a html?
you can also use an html parser and print out the objects / array as xml
try this: http://sourceforge.net/projects/html2xml/
You can try the free dotnet-classlibrary SgmlReader that can load html into a xmldocument. This in turn can be saved as xml.