Как получить элементы по имени в Delphi Chromium Embedded?

Чтобы получить конкретный узел DOM, встроенный в текущий веб-документ, из экземпляра TChromium, используя его идентификатор, вы используете ICefDomDocument.getElementById (). Но как найти элементы по атрибуту NAME? Javascript имеет метод document.getElementsByName (), а TWebBrowser (который оборачивает IE) имеет аналогичный вызов, но я не могу понять, как это сделать с TChromium. Мне нужно найти некоторые элементы DOM, которые имеют атрибуты NAME, но не имеют атрибутов ID. Я искалceflib аппарат и не видел ничего, что бы это делало.

Побочный вопрос. Если у кого-то есть ссылка на TChromium, «рецепты» Стиль сайта или документа я мог бы использовать.

ОБНОВЛЕНИЕ: ожидая ответа, я придумал следующий код для выполнения getElementsbyName (). Мне бы хотелось что-то быстрее, чем сканировать все дерево DOM. Если вы видите что-то не так в коде, дайте мне знать:

type
    TDynamicCefDomNodeArray = array of ICefDomNode;


// Given a Chromium document interface reference and a NAME attribute to search for,
//  return an array of all DOM nodes whose NAME attribute matches the desired.
function getElementsByName(ADocument: ICefDomDocument; theName: string): TDynamicCefDomNodeArray;

    // Get all the elements with a particular NAME attribute value and return
    //  an array of them.
    procedure getElementsByName1(intfParentNode: ICefDomNode; theName: string; var aryResults: TDynamicCefDomNodeArray);
    var
        oldLen: integer;
        intfChildNode: ICefDomNode;
        theNameAttr: string;
    begin
        Result := nil;
        intfChildNode := nil;

        if Assigned(intfParentNode) then
        begin
            // Attributes are case insensitive.
            theNameAttr := intfParentNode.GetElementAttribute('name');

            if AnsiSameText(theNameAttr, theName) then
            begin
                // Name attribute match.  Add it to the results array.
                oldLen := Length(aryResults);
                SetLength(aryResults, oldLen + 1);
                aryResults[oldLen] := intfParentNode;
            end; // if AnsiSameText(intfParentNode.Name, theName) then

            // Does the parent node have children?
            if intfParentNode.HasChildren then
            begin
                intfChildNode := intfParentNode.FirstChild;

                // Scan them.
                while Assigned(intfChildNode) do
                begin
                    getElementsByName1(intfChildNode, theName, aryResults);

                    if Assigned(intfChildNode) then
                        intfChildNode := intfChildNode.NextSibling;
                end;
            end; // if intfParentNode.HasChildren then
        end; // if Assigned(intfParentNode) then
    end;

    // ---------------------------------------------------------------

var
    intfCefDomNode: ICefDomNode;
begin
    intfCefDomNode := nil;
    Result := nil;

    if Assigned(ADocument) then
    begin
        // Check the header.
        intfCefDomNode := ADocument.Document;

        if Assigned(intfCefDomNode) then
        begin
            // Check the parent.
            getElementsByName1(intfCefDomNode, theName, Result);
        end; // if Assigned(intfCefDomNode) then
    end; // if Assigned(ADocoument) then
end;

// ---------------------------------------------------------------

Ответы на вопрос(1)

Ваш ответ на вопрос