We author our documentation in XML and package it to a JSON file to render it on a tablet. But, the basic inline formatting (bold, italics, superscript, and subscript) does not get converted to the JSON. It is plain text. Is there a way to get the tablet/JSON file to include the formatting? Like, attaching a CSS or something? If yes, then what's the effort?
AFAIK, XML does not include any information about formatting either, would need to look at an example on how you include that information in XML, and maybe do something similar in json.
You can use XSLT to transform XML to JSON.
There is already a stylesheet to get you started at: XSLTJSON: Transforming XML to JSON using XSLT
Related
the Qt documentation says
The Qt XML Module is provided for compatibility with older code. It
has been superseded by the QXMLStreamReader and QXMLStreamWriter
classes in the Qt Core Module.
I think we can use QDom* class to get data out of HTML before this claim ,although I never used it.
does this claim mean we can use QXmlStreamReader for pulling data out of HTML ?
I don't know the difference between XML and HTML.
XML stands for "Extensible Markup Language", whereas HTML stands for Hypertext Markup Language. In simple terms, they are not the same, or at least not used for the same purpose.
XML is a markup language that defines a set of rules for encoding documents in a format which is both human-readable and machine-readable.
HTML is the standard markup language used to create Web pages.
Looking at html and xml, they appear similar in that they both include tokens to define elements, though the elements used by HTML are of a fixed set, unlike XML whose elements are the meta-data of the document in which the elements reside.
Since XML elements can be named freely, unlike HTML, HTML can be added to a DOM document. As for being able to use QXmlStreamReader, according to this thread, it appears that you can, but note that the OP of that question has wrapped the html in an XML tag, which I expect will be required in order for the Dom document to accept parsing the data.
I need a function to convert any HTML table to a excel file!
I like to add a button to my page and once that button is clicked I pass a complete HTML table in to such a function that will generate an excel file and past the html table into the file with the same layout and design!
I appreciate any help with this request.
I am using c# and asp.net
This is a nasty trick, but it works in recent version of excel.
You just save the html table as a normal html file, then just rename it to xls. If your application is a web application use response.setHeader("Content-Disposition", "attachment; filename=order.xls").
Recent version of excel support Microsoft Office XML Formats, so if the previous solution doesn't work, you may want to try to generate the xml from the html table.
See XML Spreadsheet Reference.
What I do, is to generate the xml from excel in the xml format, then hack into it. You can implement also advanced features like automatic filters, and cool layouts. I used a template engine to generate the xml (Freemarker, it's Java stuff, but I'm sure there are template engines also for .NET)
I'd like to display some XML in the browser, but add some custom color styling, etc., to certain attributes of tags. I am able to get an essentially blank external sheet recognized:
<?xml-stylesheet href="/css/testresult.css"?>
But this seems to have the effect of making the browser display the XML as if it were HTML, i.e. it only displays tag content text and not attributes. Is there any way to get the "raw" XML display view, but with just a few tweaks to styling?
Using Firefox if that's relevant.
The thing is, when Firefox displays XML files, it uses it's own parser, so I don't see how that could be influenced by your stylesheet, as the only function of the parser is to display XML in a readable way.
Maybe you can use XSLT you do what you need, but that would require some additional work.
http://www.w3schools.com/xml/xml_xsl.asp
Have yet to see any indication it's possible.
I am trying to parse some html to switch out values of various element attributes. I decided that the most reliable way to parse the html was to use an xml parser (msxml.)
The problem is that the html I'm trying to parse contains attribute like:
<param name="flashvars" value="autoplay=false&brand=embed&cid=97%2Ftest&locale=en_US"/>
Which causes the xml parser to blow up. I figured out that I need to server.htmlencode() the value attribute in order for the xml parser to load it properly. How do I approach this?
I feel like the problem is a vicious circle. I couldn't use regex's because html is not regular enough, and now I can't use xml parsers because the html isn't "well formed"
help. How do I approach this issue? I want to be able to change attribute values with a vbscript.
Is your HTML well formed? If so you could simply use an XML DomDocument. Use XPath to find the attributes you want to replace.
You can actually use JScript serverside as well in ASP, whicdh might give you access to HTMLDom libraries you could use.
You should probably have a look at one of the libraries for cleaning up HTML, something like HTML Tidy http://www.w3.org/People/Raggett/tidy/
Your main problem is you need to do a replace on the ampersands, they need to be & in well formed XML/XHTML.
I have taken over a code base and I have to read in these html files that were generated by Microsoft Word, I think so it has all kinds of whacky inline formatting.
is there anyway to parse out all of the bad inline formatting and just get the text from this stream. I basically want a purifier programmatically so I can then apply some sensible css
You should use HTML Tidy - it's uniquitous when it comes to cleansing HTML. There's an article on DevX that describes how to do it from .NET.
in the end i just wrote a small class that did a bunch of find and replaces. not pretty but it worked.