html tag becomes to uppercase when get innerHTML by webbrowser - html

All html tags goes to uppercase letters when get body's innerHTML by webbrowser.
how should I do to get the real htmlcode?

There is no way to get the "real" HTML code from innerHTML.
By the time you read innerHTML, the HTML has already been parsed to a DOM and then discarded. innerHTML will serialise the DOM to HTML, it won't give you the original HTML.
The only way to get the original HTML would be to use XMLHttpRequest to get a fresh copy of the source code from the server and then parse it with a custom parser instead of the one built into the browser.

Related

Send html code from UI to node and adding it to a pug template

Hello so as the title says, I need to be able to fill a textbox with html code and send it to to my node backend and then out it into my pug template to show the html code writes in te textbox ( now I'm using react-quill but this always wraps the thing that I write between tags ) all the sending process is ok but I've been unable to found a way of doing this, dunno if a text area couldwork,with reacquill just work with the normal tools on the editor, but not like sending a current code with all syntax of html, like with doctype tag or the html tag

Developer used HTML form tag as XML root tag. Can't escape

I'm pulling data from a url string thats converting to XML. I have it placed on my webpage and most of it is displaying as expected. But the developer in their wisdom used an HTML tag as an XML tag <option>.
I can't share the whole thing but it's basically this url string displaying the xml below:
http://private.com/webservice6.asp?c=00000000&p=Int0000000&stock_symbols=AAPL,GE&classes=BOD,,OPTION&from=5/1/2021&to=6/1/2021&v=2&o=EVENTS
Its outputting like this:
<option>
<event_id>4ICO1KYD</event_id>
<company_id>1084</company_id>
</option>
So the browser thinks its an HTML webform select option. It's displaying the data but as one option block and I can't target the sub tags.
I have no control of the xml markup.
Is there any way of escaping or wrapping the whole thing to tell the browser to treat it as xml vs html?

Objective-C event-driven HTML parsing

I need to be able to parse HTML snippets in an event-driven way. For example, if the parser finds a HTML tag, it should notify me and pass the HTML tag, value, attributes etc. to a delegate. I cannot use NSXMLParser because I have messy HTML. Is there a useful library for that?
What I want to do is parse the HTML and create a NSAttributedArray and display it in a UITextView.
YES you can parse HTML content of file.
If you want to get specific value from HTML content you need to Parce HTML content by using Hpple. Also This is documentation with exmple that are is for parse HTML. Another way is rexeg but it is more complicated so this is best way in your case.

Valid HTML5 and img src-attribute on AngularJs ng-src

Anyone has idea, how to produce valid HTML5 when images are displayed with AngularJs ng-scr directive?
What I have discovered?
"src"- attribute is required on img-tags
It can't be empty
Console reports 404 error if I set src attribute data with angular binding, cause it tries to load image before Angular has initialized
Why I want valid HTML?
Reason is simple. Strange HTML errors (missing end tags, open tags etc..) causes strange behavior in our project where we have LOTS of views. Ensuring periodically that source is valid, makes code less unstable.
From this post stems a genious hack:
<img ng-src="modelImage" src="//:0">
...much easier to remember from the top of your head than an image URL ;)
ngSrc: any string which can contain {{}} markup.

Preventing PHP from auto parsing XML

I'm making an api call to a site using the code as shown below :
$xmlData = file_get_contents("http://isbndb.com/api/books.xml?access_key=XXXXXX&index1=isbn&value1=0596002068");
echo $xmlData;
However xmlData when displayed on the browser is auto parsed to HTML. For e.g. The element <title> of the returned XML which is actually a book title is converted to HTML essentially becoming the page title, and the other XML elements are displayed as plain text without the tags. I want the client side XMLHttpRequest Object to get raw XML data from the server side.
Why does this happen and how do I ensure that XML is not auto parsed?
PHP just sees it as text. For instance, do echo "<b>Bold</b>"; and it will "automatically" be in bold. It is the browser that processes the HTML and renders it.
This is what htmlspecialchars is for.
This got nothing to do with php. you spit out elements which browser interprets as HTML (that's why it sets title). Build your html page right, use <pre> tags around your content, or. when needed, send your content with correct content-type header (like text/plain to display your xml for viewing or text/xml for other purposes) so it will not parse your data as html.