I am generating XPaths server-side for use on the client-side, and I was puzzled as why only table paths (i.e. content in a td) couldn't be found in the DOM.
Turns out, modern browsers (at least Chrome and Firefox) insert a tbody tag around table rows upon document loading. See Why do browsers insert tbody element into table elements?
Apart from tbody, are there other DOM elements I should be aware of when calculating XPaths server-side?
In SGML/HTML4 terminology some other elements can be inferred, even the head and the body element can be inferred, and HTML5 continues that. So a document like http://home.arcor.de/martin.honnen/html/test2012011901.html is valid HTML5 although it does neither have head nor body element and any HTML5 parser is supposed to add them so the DOM tree looks like
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>
<p>This is a test.</p>
</body>
</html>
I can't tell you all details about other elements, the above is only an example. Look for details in http://www.w3.org/TR/html5/syntax.html#optional-tags.
Related
Tinymce wraps output as a full html page instead of wrapping it in paragraph or div tags as html snippets. The code below shows an output stored to database
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>Which of the numbers from the options is a prime number</p>
</body>
</html>
You likely have the fullpage plugin loaded - if you don't load that plugin TinyMCE will only allow you to work with the content inside the <body> and it will only provide the data inside the <body> when you submit the form or ask for the content via an API call.
OneNote tags on page elements (e.g. <p>) show up in the HTML content returned via the REST API prefixed with a data-tag=attribute. But if the complete note is tagged, that tag doesn't seem to show up in the returned content.
Or am I missing something?
[EDIT]
Here's a screenshot showing the complete note tagged as 'Important' (star symbol) :
I can't see anything in the returned content that relates to that tag:
<html lang="en-US">
<head>
<title>Didi Chuxing = Jean Liu</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
<div style="position:absolute;left:48px;top:67px;width:576px">
<img width="480" height="270" src="https://www.onenote.com/api/v1.0/me/notes/[...]
<br />
<p lang="en-NZ" style="font-size:14pt;margin-top:0pt;margin-bottom:0pt">credit : Fast Company</p>
</div>
</body>
</html>
[EDIT]
This question has led to a UserVoice request for this feature to be added in to the API. Only one vote so far - maybe this mention will get it more ;)
The note-tag you are showing is in the title of the page.
Currently, the OneNote API does not support returning note tags in the title. This is different to note-tags in the body, because the title tag is returned in our API as part of the HTML->head->title - other note-tags are returned within the HTML->body. I believe the right way of representing this information is to add the data-tag attribute to the HTML->head->title element.
I suggest creating a UserVoice item for this feature.
https://onenote.uservoice.com/forums/245490-onenote-developer-apis
I have to create something similar to a Facebook 'Like' button. My client would link to some custom javascript and they would put a custom dom element on their page for whatever functionality.
<head>
<script src="www.domain.com/client1.js"></script>
</head>
<body>
<my-element></my-element>
</body>
I think aot would be perfect for this scenario. Would that be a good assessment?
client1.js would be my bundled ng2 files. But what about compatibility? Will this work in all evergreen browsers? What if client1 also has ng2 files linked to their webpage?
For debug purposes, I run my page under strict XHTML while I develop it. But, right now, I realised, that such code will not work:
<!-- With header("Content-Type: application/xhtml+xml; charset=\"utf-8\"") -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!--blah blah blah-->
</head>
<body>
<form method="post" target="my_frame">
<button>Send the form!</button>
</form>
<iframe name="my_frame" src="about:blank"></iframe>
</body>
</html>
Try it here. And also try it with text/html content-type. I can, of course, disable the strict mode for the site, but here on SO my question is, how to get it to work a XHTML. (this means, how to make the 1. link work properly).
Fun fact: While testing the example, I noticed that <button> tag does not work in IE properly. Any ideas what's wrong? (that's side question of course)
For XHTML, use id rather than name as the attribute for the target on the iframe. For HTML/XHTML compatibility, use both a name and an id and make sure their values are the same.
However, take note that target is not a valid attribute on a form. So it won't validate, and its working is not guaranteed.
The IE one should have been another question, but IE needs type="submit" for buttons, even if that type is supposed to be the default.
I have article pages where the only content on the page is the article. When marking up pages with schema.org microdata, is it best to define the itemscope and itemtype at the very top in the <html> tag? Or in the <body> tag? Or a <div> in the body? Or does it not matter?
Example of defining in <html> tag:
<html lang="en" itemscope itemtype="http://schema.org/Article">
<body>
<div>
<span itemprop="name">How to Tie a Reef Knot</span>
...
</div>
</body>
</html>
Versus a <div> in the body:
<html>
<body>
<div itemscope itemtype="http://schema.org/Article">
<span itemprop="name">How to Tie a Reef Knot</span>
...
</div>
</body>
</html>
Is one better than the other in terms of SEO? It seems like it would be best to define it as close to the top of the page as possible (ie, <html> tag) so the search engine spiders pick it up immediately.
If you inspect this very page, you will find that the html tag does indeed include schema.org metadata
<html itemscope="" itemtype="http://schema.org/QAPage">
Not everyone does this, but stackoverflow is a top 100 website- take that for what its worth.
Obviously, you will want schema.org metadata throughout the page as well.
Doesn't matter, in the sense that either will work and neither is "wrong". Where you put these things depends very much on what information's on your page, and how it's arranged (e.g., some schemas can't go inside certain other ones). However, though it's actually implied, you might want to put WebPage on the body element, be more specific from there on down through your page code.
There's absolutely no difference in terms of SEO, partly because it doesn't matter if the microdata is parsed a fraction of a microsecond earlier, and partly because only a few select bits of microdata are currently used by major search engines (of which Article isn't one), and Google have explicitly stated there's no effect on ranking (yet).
You need to put that on div tag as your article is enclosed under it at the lowest level..so when a search engine spider will crawl your page, it can more appropriately index your article content..
Although your pages contain only articles but still they may contain other portions such as menus, author information, etc.