Page 1 of 1

Where does HTML 'id' attribute map to in the DOM?

PostPosted: Fri Dec 07, 2018 11:51 pm
by _savage
Suppose I have a simple HTML file like so:
Code: Select all   Expand viewCollapse view
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="../style/stylesheet.css" type="text/css" rel="stylesheet"/>
  </head>
  <body class="b">
    <p id="p-001" class="par">Content</p>
    <p class="par">Some bla</p>
    <!-- A reference to a paragraph in a neighboring file. -->
    <p id="id=p-003" class="par">…<a href="../text/page-2.html#p-021" class="link">Link</a>…</p>
    …
    <!-- An internal reference to a paragraph in this file. -->
    <p id="id=p-009" class="par">…<a href="#p-001" class="link">Top</a>…</p>
    …
  </body>
</html>

Notice how some paragraphs (and in HTML potentially many/most elements) have an “id” attribute here. The third paragraph then contains a link to a paragraph in a different file.

Loading this file into Office and browsing around its DOM, I am unable to find where the “id” attribute is stored for the paragraph. Not quite sure which interface or service would give me access to that value—if any. Some help would be good, short of digging into the source code for the HTML filter…

Re: Where does HTML 'id' attribute map to in the DOM?

PostPosted: Sat Dec 08, 2018 2:47 pm
by YODA
I personally would use a dedicated html editor like Blue Griffon available at http://bluegriffon.org/ instead.

Re: Where does HTML 'id' attribute map to in the DOM?

PostPosted: Mon Dec 10, 2018 12:25 pm
by RoryOF
In an administrative query the OP asked if "he could delete postings that were irrelevant to him".

I replied as follows
You may only delete your own postings, which we discourage, as it is antisocial and contrary to the spirit of the Forum.

If you feel a posting is irrelevant to you simply ignore it; in OO there are often many ways to achieve a given target - your "irelevancy" may be someone else's lifeline.


I agree with YODA that a dedicated HTML editor may be best; OO does not generate good HTML code.

Re: Where does HTML 'id' attribute map to in the DOM?

PostPosted: Mon Dec 10, 2018 2:22 pm
by _savage
I wasn’t asking about producing HTML code, but about reading HTML code into Office. To answer the above question, it seems that HTML elements with an `id` attribute produce a bookmark in the DOM.

Re: Where does HTML 'id' attribute map to in the DOM?

PostPosted: Mon Dec 10, 2018 9:41 pm
by Villeroy
YOU are the developer of your program. Lookup the Open Document Format specification and the content.xml of an example document where you inserted a bookmark.