Document object model updating processing method, electronic equipment and storage medium

By determining priorities based on node text content and update time difference during document object model update processing, matching target nodes across levels and using a multi-dimensional distance strategy, the contradiction between real-time performance and accuracy of DOM updates is resolved, achieving efficient DOM update processing.

CN120973804APending Publication Date: 2025-11-18XCMG HANYUN TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202511090838.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-05
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

Front-end frameworks face a contradiction between the high-frequency update requirements of dynamic content and the computational efficiency bottleneck of traditional difference algorithms when updating the Document Object Model (DOM), making it difficult to balance real-time performance and accuracy.

Method used

By acquiring the node sequence of the new document model tree, prioritizing the new nodes based on their text content and update time difference, matching target nodes across levels, and determining update strategies based on multi-dimensional distance, including in-situ updates, local re-rendering, and node reconstruction, the matching process is optimized using GPU parallel computing and dynamic weight adjustment algorithms.

Benefits of technology

It improves the real-time performance and accuracy of DOM updates, reduces unnecessary global searches and calculations, enhances matching accuracy and computational efficiency, and reduces memory usage and resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120973804A_ABST
    Figure CN120973804A_ABST
Patent Text Reader

Abstract

The invention provides a document object model updating processing method, electronic equipment and a storage medium. The method comprises the steps of obtaining a node sequence of a new document model tree; according to the text content of each new node and an update time difference, determining the priority of each new node, the update time difference being used for indicating the time difference between a new document model tree and the current time; traversing the new nodes in sequence according to the priorities of the new nodes, and for the traversed current new node, determining a target node matched with the current new node from an old document model tree; determining a multi-dimensional distance between the current new node and the target node, and determining a target updating strategy according to the multi-dimensional distance; and updating the target node according to the target updating strategy and the current new node. And the real-time performance and the accuracy of updating processing of the document object model are improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a document object model updating processing method, an electronic device and a storage medium. BACKGROUND

[0002] The document object model (DOM) is an application programming interface (API) for representing and interacting with document contents. In a front-end framework, the content of a webpage is generally changed by updating the DOM.

[0003] The target is that the front-end framework faces the following core contradictions when updating the DOM: the contradiction between the high-frequency update requirement of dynamic content and the calculation efficiency bottleneck of the traditional difference algorithm (Diff) algorithm. In addition, with the increase of the complexity of the Web application, the real-time performance and accuracy of the DOM update also need to be considered. Therefore, how to improve the real-time performance of the DOM update while considering the real-time performance and accuracy is a problem to be solved. SUMMARY

[0004] The present application aims at the deficiencies in the prior art, and provides a document object model updating processing method, an electronic device and a storage medium, to improve the real-time performance and accuracy of the document object model updating processing.

[0005] To achieve the above object, the technical solutions adopted by the embodiments of the present application are as follows: In a first aspect, the embodiments of the present application provide a document object model updating processing method, which comprises: obtaining a node sequence of a new document model tree, the node sequence comprising a plurality of new nodes, each new node comprising a hierarchical structure, attributes, styles and text content; determining the priority of each new node according to the text content and the update time difference of each new node, the update time difference being used to indicate the time difference between the new document model tree and the current time; sequentially traversing each new node according to the priority of each new node, and determining a target node matching the current new node from an old document model tree for the current new node traversed; determining the multi-dimensional distance between the current new node and the target node, and determining a target update strategy according to the multi-dimensional distance; updating the target node according to the target update strategy and the current new node.

[0006] Optionally, the priority of each new node is determined according to the text content of each new node and the update time difference, and the priority of each new node comprises: key feature extraction is performed on the text content of each new node to obtain a plurality of features corresponding to each new node, and weights of the plurality of features are determined; the feature with the highest weight corresponding to each new node is taken as the key feature of each new node; a target weight of each new node is determined according to the feature value of each key feature and the update time difference; the priority of each new node is determined according to the size of the target weight of each new node.

[0007] Optionally, the target node matching the current new node is determined from the old document model tree, comprising: fingerprint information of the current new node is determined, the fingerprint information being used to indicate the hierarchical path of the current new node in the new document model tree; cross-hierarchical node matching is performed according to the fingerprint information of the current new node from the old document model tree to obtain the target node.

[0008] Optionally, the multi-dimensional distance between the current new node and the target node is determined, comprising: semantic similarity, structural similarity and time sequence proximity between the current new node and the target node are determined; the multi-dimensional distance is determined according to the semantic similarity, the structural similarity and the time sequence proximity.

[0009] Optionally, the semantic similarity, the structural similarity and the time sequence proximity between the current new node and the target node are determined, comprising: a new text vector of the current new node, a new node depth, a new sibling node index, an old text vector, an old node depth and an old sibling node index of the target node, an update time difference and attribute information of the current new node are obtained, the attribute information being used to indicate appearance frequency information, depth information and update frequency information of the current new node; the semantic similarity is determined according to the new text vector, the old text vector and the attribute information of the current new node; the structural similarity is determined according to the new node depth, the new sibling node index, the old node depth, the old sibling node index and the attribute information of the current new node; the time sequence proximity is determined according to the update time difference and the attribute information of the current new node.

[0010] Optionally, the determining the semantic similarity according to the new text vector, the old text vector, and attribute information of the current new node comprises: calculating a cosine similarity between the new text vector and the old text vector; determining whether the current new node is a low-frequency node according to frequency information in the attribute information; if yes, taking a product of the cosine similarity and a first preset value as the semantic similarity; and if no, taking the cosine similarity as the semantic similarity.

[0011] Optionally, the determining the structural similarity according to the new node depth, the new sibling node index, the old node depth, the old sibling node index, and the attribute information of the current new node comprises: calculating a difference between the new node depth and the old node depth to obtain a depth difference; calculating a difference between the new sibling node index and the old sibling node index to obtain an index difference; determining whether the current new node is a deep node according to depth information in the attribute information; if yes, determining the structural similarity according to the depth difference, the index difference, a depth proportion value, an index proportion value, and a second preset value; and if no, determining the structural similarity according to the depth difference, the index difference, the depth proportion value, and the index proportion value.

[0012] Optionally, the determining the target update strategy according to the multi-dimensional distance comprises: if the multi-dimensional distance is less than or equal to a first preset threshold, determining that the target update strategy is an in-place update attribute strategy, the in-place update attribute strategy being used to indicate that a value of the new node is taken as a value of the target node; if the multi-dimensional distance is greater than the first preset threshold and less than a second preset threshold, determining that the target update strategy is a local re-rendering strategy, the second preset threshold being greater than the first preset threshold, the local re-rendering strategy being used to indicate that an image of the target node is redrawn as an icon of the new node; if the multi-dimensional distance is greater than or equal to the second preset threshold, determining that the target update strategy is a node reconstruction strategy, the node reconstruction strategy being used to indicate that the target node is replaced by the new node.

[0013] In a second aspect, an embodiment of the present application further provides a document object model update processing device, the device comprising: an obtaining module configured to obtain a node sequence of a new document model tree, the node sequence comprising a plurality of new nodes, each of the new nodes comprising a hierarchical structure, attributes, styles, and text content; The determining module is configured to determine a priority of each of the new nodes according to the text content of each of the new nodes and an update time difference, the update time difference being used to indicate a time difference between the new document model tree and a current time; The determining module is configured to sequentially traverse each of the new nodes according to the priority of each of the new nodes, and determine a target node matching the current new node from the old document model tree for the current new node traversed; The determining module is configured to determine a multi-dimensional distance between the current new node and the target node, and determine a target update strategy according to the multi-dimensional distance; The updating module is configured to update the target node according to the target update strategy and the current new node.

[0014] Optionally, the determining module is specifically configured to: extract key features from the text content of each of the new nodes to obtain a plurality of features corresponding to each of the new nodes, and determine weights of the plurality of features; take the feature with the highest weight corresponding to each of the new nodes as a key feature of each of the new nodes; determine a target weight of each of the new nodes according to a feature value of each of the key features and the update time difference; determine the priority of each of the new nodes according to the size of the target weight of each of the new nodes.

[0015] Optionally, the determining module is specifically configured to: determine fingerprint information of the current new node, the fingerprint information being used to indicate a hierarchical path of the current new node in the new document model tree; perform cross-hierarchical node matching from the old document model tree according to the fingerprint information of the current new node to obtain the target node.

[0016] Optionally, the determining module is specifically configured to: determine semantic similarity, structural similarity and time sequence proximity between the current new node and the target node; determine the multi-dimensional distance according to the semantic similarity, the structural similarity and the time sequence proximity.

[0017] Optionally, the determining module is specifically configured to: obtain a new text vector of the current new node, a new node depth, a new sibling node index, an old text vector, an old node depth and an old sibling node index of the target node, an update time difference and attribute information of the current new node, the attribute information being used to indicate occurrence frequency information, depth information and update frequency information of the current new node; determine the semantic similarity according to the new text vector, the old text vector, and attribute information of the current new node; determine the structural similarity according to the new node depth, the new sibling node index, the old node depth, the old sibling node index, and the attribute information of the current new node; determine the time sequence proximity according to the update time difference and the attribute information of the current new node.

[0018] Optionally, the determining module is specifically configured to: calculate a cosine similarity between the new text vector and the old text vector; determine whether the current new node is a low-frequency node according to frequency information in the attribute information; if yes, take a product of the cosine similarity and a first preset value as the semantic similarity; and if no, take the cosine similarity as the semantic similarity.

[0019] Optionally, the determining module is specifically configured to: calculate a difference between the new node depth and the old node depth to obtain a depth difference; calculate a difference between the new sibling node index and the old sibling node index to obtain an index difference; determine whether the current new node is a deep layer node according to depth information in the attribute information; if yes, determine the structural similarity according to the depth difference, the index difference, a depth proportion value, an index proportion value, and a second preset value; and if no, determine the structural similarity according to the depth difference, the index difference, the depth proportion value, and the index proportion value.

[0020] Optionally, the determining module is specifically configured to: if the multi-dimensional distance is less than or equal to a first preset threshold value, determine that the target update strategy is a local attribute update strategy, the local attribute update strategy being used to indicate that a value of the new node is taken as a value of the target node; if the multi-dimensional distance is greater than the first preset threshold value and less than a second preset threshold value, determine that the target update strategy is a local re-rendering strategy, the second preset threshold value being greater than the first preset threshold value, the local re-rendering strategy being used to indicate that an image of the target node is redrawn as an icon of the new node; if the multi-dimensional distance is greater than or equal to the second preset threshold value, determine that the target update strategy is a node reconstruction strategy, the node reconstruction strategy being used to indicate that the target node is replaced by the new node.

[0021] In a third aspect, the embodiments of the present application further provide an electronic device, comprising a processor, a storage medium and a bus, the storage medium stores program instructions executable by the processor, when an application program is running, the processor and the storage medium communicate through the bus, the processor executes the program instructions to execute the steps of the document object model updating processing method in the first aspect.

[0022] In a fourth aspect, the embodiments of the present application further provide a computer readable storage medium, the computer readable storage medium stores a computer program, the computer program is read and executes the steps of the document object model updating processing method in the first aspect.

[0023] The beneficial effects of the present application are: The document object model updating processing method, the electronic device and the storage medium provided by the present application can determine the priority of each new node according to the text content and the update time difference of each new node by obtaining the node sequence of the new document model tree. The matching priority of the node that is updated most recently can be given higher, so that the matching node matches the node that is changed most recently, unnecessary global search and calculation are reduced, and the matching accuracy is improved. After the priority of each new node is determined, each new node is traversed according to the priority of each new node, and the target node that matches the current new node is determined from the old document model tree. The multidimensional distance between the current new node and the target node is determined, and the target updating strategy is determined according to the multidimensional distance. The target node is updated according to the target updating strategy and the current new node. Different updating strategies are used for different distances, so that the node can be updated more accurately. BRIEF DESCRIPTION OF DRAWINGS

[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.

[0025] Figure 1 A flowchart of a document object model updating processing method provided by the embodiments of the present application; Figure 2 A flowchart of a second document object model updating processing method provided by the embodiments of the present application; Figure 3 A flowchart of a third document object model updating processing method provided by the embodiments of the present application; Figure 4A flowchart of a fourth document object model updating processing method provided by an embodiment of the present application is shown in FIG. 4; Figure 5 A flowchart of a fifth document object model updating processing method provided by an embodiment of the present application is shown in FIG. 5; Figure 6 A device diagram of a document object model updating processing method provided by an embodiment of the present application is shown in FIG. 6; Figure 7 A structure block diagram of an electronic device provided by an embodiment of the present application is shown in FIG. 7. DETAILED DESCRIPTION

[0026] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below in connection with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application are only intended to illustrate and describe the present application, and are not intended to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn according to the actual proportions. The flowchart shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can not be implemented in sequence, and the steps without logical context relationship can be reversed in sequence or implemented simultaneously. In addition, one or more other operations can be added to the flowchart or one or more operations can be removed from the flowchart under the guidance of the content of the present application.

[0027] In addition, the described embodiments are only some of the embodiments of the present application, not all the embodiments. The components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the claimed present application, but only represents selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.

[0028] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.

[0029] Document Object Model (DOM) is a standard programming interface recommended by W3C organization to process Extensible Markup Language (XML). In a webpage, objects of a page or a document are organized in a tree structure, and a standard model to represent objects in a document is called DOM. DOM can access and modify content and structure of a document in a platform-independent and language-independent manner. That is, it is a common method to represent and process an HTML or XML document. DOM is designed based on a specification of Object Management Group (OMG), and thus can be used in any programming language. DOM technology enables a user page to dynamically display or hide an element, change attributes of the element, add an element, etc., and greatly enhances interactivity of the page.

[0030] Optionally, the document object model updating processing method provided in the embodiments of the present application is applied to an electronic device, which can be a terminal device with computing processing capability and display function, such as a mobile phone, a tablet computer, a notebook computer, a palm computer, a desktop computer, or a server. The method can be applied to an application program in the terminal device, such as an application program (application, APP) of a mobile phone or an application system on a computer.

[0031] Figure 1 A flowchart of a document object model updating processing method provided in the embodiments of the present application is shown in FIG. 1. The execution subject of the method is an electronic device as described above. As shown in FIG. 1, the method comprises the following steps. Figure 1 S101, acquiring a node sequence of a new document model tree.

[0032] The node sequence of the new document model tree can include a plurality of new nodes, and each new node can include a hierarchical structure, attributes, styles, and text content. The hierarchical structure refers to hierarchical information of the new node in the new document model tree, the attributes refer to attribute information of the new node in the new document model tree, and the attributes can be, for example, id, class, style, etc. The styles can refer to, for example, color, size, and positioning of the new node, etc. The text content can refer to text content of the new node, for example, "Hello World!". Temperature: 42°C

[0033] For a document, a tree structure can be parsed, such as an old document model tree. If the document is updated, the document corresponds to a new tree structure, such as a new document model tree.

[0034] S102, determining a priority of each new node according to the text content and an update time difference of each new node.

[0035] ​​The update time difference refers to a time difference between the new document model tree and the current time.

[0036] Specifically, the weight of each new node can be determined by using a preset method according to the text content and the update time of each new node. For the same node, the weight of the node is different when the update time difference is different. Therefore, the weight of a node can be determined by introducing a time dimension, so that the latest changed new node can be matched subsequently, unnecessary global search and calculation are reduced, and the problem that the historical node and the newly updated node cannot be distinguished in the prior art, resulting in mismatching, can be avoided. In addition, for different nodes updated at the same time difference, the priority of each new node can be determined according to the text content of each new node, so that the new node with high priority can be updated first when matching subsequently based on the priority of each new node.

[0037] S103, sequentially traversing each new node according to the priority of each new node, and determining a target node matched with the current new node from the old document model tree for the current new node.

[0038] The old document model tree refers to a tree structure when the document is not updated.

[0039] Optionally, each new node can be sequentially traversed in a high-to-low order according to the priority of each new node, and a target node matched with the current new node can be determined from the old document model tree by using a preset method for the current new node.

[0040] For example, if the current new node is “current temperature” and the node matched with the current new node in the old document model tree is “numeric label”, the target node is “numeric label”.

[0041] S104, determining a multi-dimensional distance between the current new node and the target node, and determining a target update strategy according to the multi-dimensional distance.

[0042] The update strategy corresponding to different multi-dimensional distances is different. The update strategy can include an in-place attribute updating strategy, a local re-rendering strategy, and a node reconstruction strategy.

[0043] Optionally, after the target node of the current new node is determined, different similarities between the current new node and the old node can be calculated, and then the multi-dimensional distance between the current new node and the target node can be calculated according to the different similarities between the current new node and the old node by using a preset method, so as to determine the target update strategy according to the multi-dimensional distance. The target update strategy refers to updating the target node based on the target update strategy.

[0044] S105, updating the target node according to the target update strategy and the current new node.

[0045] Optionally, after determining the target update strategy, the target node can be updated according to the target update strategy.

[0046] In this embodiment, after obtaining the node sequence of the new document model tree, the priority of each new node is determined according to the text content and the update time difference of each new node. A higher matching priority can be given to the node that is updated most recently, so as to ensure that the matching node matches the node that is changed most recently, reduce unnecessary global search and calculation, and improve the accuracy of matching. After determining the priority of each new node, each new node is traversed in turn according to the priority of each new node, and the target node that matches the current new node is determined from the old document model tree for the current new node that is traversed. The multidimensional distance between the current new node and the target node is determined, and the target update strategy is determined according to the multidimensional distance. The target node is updated according to the target update strategy and the current new node. Different update strategies are used for different distances, so that the update of the node can be more accurately realized.

[0047] Figure 2 The flowchart of the second document object model update processing method provided by the embodiment of the present application is shown in FIG. 2, which can include the following steps. Figure 2 As shown in FIG. 2, S102, determining the priority of each new node according to the text content and the update time difference of each new node, can include: S201, extracting the key features of the text content of each new node to obtain a plurality of features corresponding to each new node, and determining the weight of each feature.

[0048] Specifically, the text semantic analysis can be performed on the text content of each new node, and the key word weight distribution of the text content of each new node is extracted based on the IF-IDF algorithm to obtain the weight of each feature.

[0049] For example, for the new node “ Temperature: 42°C ”, the features obtained are “temperature”, “42”, and “℃”, wherein the weight of “temperature” is 0.65, the weight of “42” is 0.28, and the weight of “℃” is 0.07, and the IF-IDF vector [temperature: 0.65, 42: 0.28, ℃: 0.07] is obtained based on each feature and the weight of each feature.

[0050] S202, taking the feature with the highest weight corresponding to each new node as the key feature of each new node.

[0051] For example, the weight of “temperature” is the highest in the foregoing, so “temperature” is taken as the key feature of the new node.

[0052] S203, determine the target weight of each new node according to the feature value of each key feature and the update time difference.

[0053] Optionally, after obtaining the key features of each new node, the feature value of the key features of each new node can be determined, and then the target weight of each new node is determined according to the feature value of the key features of each new node and the update time difference. The update time difference refers to the time difference between the update time of the new node and the current time, that is, the update time difference in S102. Specifically, the formula: target weight = current new node feature value x exp(-Δt / 500ms) can be used to obtain, where Δt / is the update time difference, and the current new node feature value refers to the feature value of the key features of the current new node.

[0054] S204, determine the priority of each new node according to the size of the target weight of each new node.

[0055] Specifically, the greater the target weight of the new node, the higher the priority of the new node.

[0056] Table 1 below is a comparison between the results of introducing a time decay factor in the present application and not introducing a time decay factor in the prior art.

[0057]

[0058] Table 1 In this embodiment, the introduction of the time exponential decay function determines the weight of the node according to the update time difference of the node, thereby determining the priority of the node. The introduction of the time decay factor effectively improves the matching accuracy and significantly reduces the resource consumption.

[0059] Figure 3 The flowchart of the third document object model update processing method provided in the embodiment of the present application is shown in Figure 3 As shown in the above S103, the target node matched with the current new node in the old document model tree can include: S301, determine the fingerprint information of the current new node.

[0060] The fingerprint information refers to the hierarchical path of the current new node in the new document model tree.

[0061] Specifically, the SHA-256 algorithm can be used to perform iterative hash operation on the parent node fingerprint, tag name and key attributes (such as id, class) of the current new node to generate a unique hierarchical identifier of the current new node, that is, the fingerprint information of the current new node.

[0062] For example, the node The fingerprint generation process of the current new node is: parent node fingerprint (SHA-256) + "div" + SHA-256 ("class_chart"), and a 64-bit hash value is obtained, which is the fingerprint information of the current new node.

[0063] S302, cross-level node matching is performed from the old document model tree according to the fingerprint information of the current new node, and a target node is obtained.

[0064] Optionally, a hierarchical path matching the fingerprint information of the current node can be found from the old document model, and a path end point in the matching hierarchical path is taken as the target node.

[0065] For example, if the fingerprint information of the current new node is B1 (Root) --> B2 [warning panel] --> B3 [threshold monitoring] --> B4 [real-time reading] --> B5 [current temperature], and the hierarchical path matching the fingerprint information of the current new node in the old document model is A1 (Root) --> A2 [device panel] --> A3 [sensor group] --> A4 [temperature table] --> A5 [numeric label], then the target node of the current new node is "numeric label".

[0066] Specifically, the path search range can be dynamically expanded according to the DOM tree depth, and the window size increases in steps with the increase of the hierarchical depth. In this embodiment, node matching across a maximum of 5 levels is allowed, breaking the constraint of traditional algorithms that are limited to same-level matching, and the processing capability of complex DOM structures can be significantly improved.

[0067] Optionally, the above S104, determining the multi-dimensional distance between the current new node and the target node, can include: Specifically, the semantic similarity, the structural similarity and the time sequence proximity between the current new node and the target node can be determined, and the multi-dimensional distance between the current node and the target node is determined according to the semantic similarity, the structural similarity and the time sequence proximity.

[0068] Specifically, the multi-dimensional distance can be obtained using the following formula: multi-dimensional distance = a x semantic similarity + b x structural similarity + g x time sequence proximity. Wherein, a + b + g = 1, wherein a can be 0.5, b can be 0.3, and g can be 0.2.

[0069] Figure 4 The flowchart of the fourth document object model updating processing method provided by the embodiment of the application is shown in Figure 4 As shown in the above, the determination of the semantic similarity, the structural similarity and the time sequence proximity between the current new node and the target node can include: S401, acquire a new text vector of a current new node, a new node depth, a new sibling node index, an old text vector of a target node, an old node depth, and an old sibling node index, an update time difference, and attribute information of the current new node.

[0070] The attribute information refers to appearance frequency information, depth information, and update frequency information of the current new node. The update time difference refers to a time difference between the current new node and a current time.

[0071] Optionally, the text vector can be extracted using an ID-IDF algorithm, such as the IF-IDF vector [temperature: 0.65, 42: 0.28, ℃: 0.07] in the foregoing. The appearance frequency information of the current new node can be determined according to the text content, attribute value, and style matrix of the current new node. The style matrix can be a CSSOM style matrix. The appearance frequency information of the current new node can include a low-frequency node or a non-low-frequency node. Specifically, if the vocabulary document frequency in the text content of the current new node is less than 0.1%, the appearance frequency of the attribute value is less than 1%, and the usage rate of the style matrix is less than 5%, the current new node is determined to be a low-frequency node.

[0072] Optionally, the attribute value of the current new node can be One-Hot encoded to realize the numerical expression of discrete attributes, and 18 high-frequency attributes such as id, class, style, etc. are mapped to a 128-dimensional feature space. For example, the current new node "{id: "sensor-1", class: "active"}” is encoded as One-Hot encoding of id + One-Hot encoding of class. The style of the current new node, such as color, size, and positioning, can be quantized as a 16-order gray matrix. For example, color: rgb(255, 0, 0) is converted into matrix row [255, 0, 0], size: width: 100px is converted into matrix row [100, 0, 0], and positioning: position: absolute is converted into matrix row [0, 0, 1].

[0073] S402, determine a semantic similarity according to the new text vector, the old text vector, and the attribute information of the current new node.

[0074] Specifically, the semantic similarity between the current new node and the target node can be determined using a preset method according to the IF-IDF vector of the current new node and the IF-IDF vector of the target node, and the attribute information of the current node.

[0075] S403, determine a structural similarity according to the new node depth, the new sibling node index, the old node depth, the old sibling node index, and the attribute information of the current new node.

[0076] Wherein, the new node depth can be denoted as d_new, the old node depth can be denoted as d_old, the new sibling node index can be denoted as idx_new, and the old sibling node index can be denoted as idx_old.

[0077] Specifically, the structural similarity between the current new node and the target node can be determined according to the new node depth of the current new node, the new sibling node index of the current new node, the old node depth of the target node, the old sibling node index of the target node, and the attribute information of the current new node, by using a preset method.

[0078] S404, determining the time proximity according to the update time difference and the attribute information of the current new node.

[0079] Specifically, if the update frequency of the current new node is greater than a preset frequency threshold, it is determined that the current node belongs to a high-frequency scenario, wherein the preset frequency threshold can be 30 Hz, that is, if the update frequency of the current new node is greater than 30 Hz, it is determined that the update frequency of the current new node is high, that is, the current new node belongs to a high-frequency scenario.

[0080] Optionally, if the current new node belongs to a high-frequency scenario, the time proximity = 1.6 x (1 - e^(-Δt / 500)). If the current new node does not belong to a high-frequency scenario, the time proximity = 1 - e^(-Δt / 500). Wherein, Δt is the update time difference, that is, the time difference between the current new node and the current time.

[0081] In this embodiment, the semantic similarity, the structural similarity and the time proximity are comprehensively determined to determine the comprehensive distance between the current new node and the target node, which can make the determined multi-dimensional distance more accurate.

[0082] Optionally, the above S402, determining the semantic similarity according to the new text vector, the old text vector and the attribute information of the current new node, can include: Specifically, the cosine similarity between the new text vector and the old text vector is calculated, cosθ = (A·B) / (|A||B|), wherein A can be the new text vector and B can be the old text vector. After determining the cosine similarity between the current new node and the target node, it can be determined whether the current new node is a low-frequency node according to the appearance frequency information in the attribute information of the current new node.

[0083] Specifically, if the current new node is a low-frequency node, the product of the cosine similarity and a first preset value is taken as the semantic similarity; if the current new node is a non-low-frequency node, the cosine similarity is taken as the semantic similarity. Wherein, the first preset value is 1.5.

[0084] For example, if the current new node " <label>Thermocouple probe< / label> "and the target node is" <label>Temperature sensor< / label> The cosine similarity between the nodes is 0.4. Since the new node is a low-frequency node, the new node... <label>Thermocouple probe< / label> "and the target node is" <label>Temperature sensor< / label> The semantic similarity between “” and “” is 0.6.

[0085] In this embodiment, the similarity of low-frequency nodes is weighted and adjusted to obtain a weighted semantic similarity, which makes subsequent calculation of multi-dimensional distance more accurate.

[0086] Figure 5 A flowchart illustrating the fifth document object model update processing method provided in this application embodiment is shown below. Figure 5 As shown, S403 above, determining structural similarity based on the new node depth, the new sibling node index, the old node depth, the old sibling node index, and the attribute information of the current new node, may include: S501. Calculate the difference between the depth of the new node and the depth of the old node to obtain the depth difference.

[0087] Specifically, the depth difference can be calculated using the formula |d_old - d_new|, where d_new is the depth of the new node and d_old is the depth of the old node.

[0088] S502. Calculate the difference between the index of the new sibling node and the index of the old sibling node to obtain the index difference.

[0089] Specifically, the index difference can be calculated using the formula |idx_old - idx_new|, where idx_new is the index of the new sibling node and idx_old is the index of the old sibling node.

[0090] S503. Determine whether the current new node is a deep node.

[0091] Specifically, the depth information in the attribute information can be used to determine whether the current new node is a deep node. If the depth of the current new node is greater than or equal to 7, then the current new node is a deep node; if the depth of the current new node is less than 7, then the current new node is a non-deep node.

[0092] Specifically, if the current new node is a deep node, then execute step S504 below; if the current new node is a non-deep node, then execute step S505 below.

[0093] S504. Determine the structural similarity based on the depth difference, index difference, depth ratio, index ratio, and the second preset value.

[0094] Specifically, the depth difference is multiplied by a second preset value to obtain a weighted depth difference, where the second preset value can be 1.3. The structural similarity can be obtained according to the following formula: structural similarity = depth proportion value x weighted depth difference + index proportion value x index difference. The depth proportion value can be 0.7, and the index proportion value can be 0.3.

[0095] For example, if the current new node is a deep node and the depth difference between the current new node and the target node is 3, the weighted depth difference is 3.9.

[0096] S505, according to the depth difference, the index difference, the depth proportion value and the index proportion value, determine the structural similarity.

[0097] Specifically, the structural similarity = depth proportion value x depth difference + index proportion value x index difference is used to calculate the comprehensive value, where the depth proportion value can be 0.7 and the index proportion value can be 0.3.

[0098] Optionally, the determination of the target update strategy according to the multi-dimensional distance in S104 can include: If the multi-dimensional distance is less than or equal to a first preset threshold, the target update strategy is determined to be a local update attribute strategy, which is used to indicate that the value of the new node is taken as the value of the target node. The first preset threshold can be 0.1. For example, the temperature value "42℃" is updated to "45℃".

[0099] If the multi-dimensional distance is greater than the first preset threshold and less than a second preset threshold, the target update strategy is determined to be a local re-rendering strategy, the second preset threshold is greater than the first preset threshold, and the local re-rendering strategy is used to indicate that the image of the target node is redrawn as the icon of the new node. The second preset threshold can be 0.3. For example, the temperature unit "℃" is updated to "℉".

[0100] If the multi-dimensional distance is greater than or equal to the second preset threshold, the target update strategy is determined to be a node reconstruction strategy, which is used to indicate that the target node is replaced by the new node. For example, the "temperature sensor" is updated to the "humidity sensor".

[0101] Optionally, in the present embodiment, the DTW path matrix calculation task can be decomposed into thread blocks that can be executed in parallel when performing node matching, and GPU acceleration in a browser environment is realized by using WebGL. Tests show that this optimization can increase the calculation speed by 8.3 times.

[0102] Optionally, for fuzzy matching nodes, template cloning and XPath positioning techniques can be used to ensure the continuity of user interaction state during local update by capturing the internal state of sub-components such as form input values, scroll positions. Among them, the fuzzy matching node can refer to the node matching when the multi-dimensional distance is greater than or equal to the second preset threshold.

[0103] In the embodiment, for memory optimization, 5-pin DOM snapshots can be retained through a sliding window, which can reduce memory occupancy by 62%. For the problem of interruption recovery, DTW matrix state serialization storage can be used, which can reduce the frame loss rate to 3%. For cross-frame compatibility problems, the lifecycle hook can be used for interception in the embodiment, which can reduce the migration cost by 85%.

[0104] In the embodiment, under the scale of 10,000 nodes, the difference calculation time is reduced from 182ms of React Fiber to 89ms (51.1% reduction), and it shows a linear growth trend with the increase of node number (the traditional scheme is exponential growth). In the continuous data stream scenario, the average frame rate is increased from 45 FPS to 58 FPS, and the frame loss rate is reduced from 22% to less than 3%. Through cross-level movement identification, in the 300 cross-level use cases of W3C DOM test set, the correct identification rate is increased from 72% to 96%, and the misoperation is reduced by 83%.

[0105] In the embodiment, through the fusion of TF-IDF and CSSOM features, the text style synchronous update accuracy rate reaches 99.2%, avoiding the style misplacement problem caused by node reuse in the traditional scheme, and the semantic consistency can be maintained.

[0106] In the embodiment, the Chrome memory analysis in the above specific embodiment can reduce the memory consumption from 148MB of React to 62MB, and the GC (garbage collection) frequency is reduced by 75%. After running continuously for 1 hour on an iOS device, the average CPU temperature is reduced by 6.2℃, and the battery power consumption is reduced by 18%.

[0107] The prior art reduces node displacement operations by finding the longest common part of the new and old DOM node sequences, but this method only supports sequential fine-tuning and cannot handle tree structure topology changes, and still requires time complexity in complex scenarios. LSTM neural networks can also be used to learn user interaction patterns and predict DOM change paths, but a large amount of training data needs to be collected, the prediction accuracy in the cold start stage is less than 40%, and the model inference time cannot meet the real-time requirements. Through the nonlinear matching capability in the application, i.e., the DTW algorithm allows the elastic stretching and error matching of node sequences, perfectly adapts to the dynamic topology changes of the DOM tree, and through GPU parallelization and interrupt recovery mechanism, the whole process calculation can be completed within 16 ms of rendering period, without the need for pre-collection of data sets or training of models, and the out-of-box feature significantly reduces the deployment threshold.

[0108] In the embodiment, the semantic content, structural position and time decay factor of the DOM node are combined to construct a multi-dimensional feature space, solving the mismatching problem caused by single-dimensional comparison in traditional schemes. The dynamic weight adjustment algorithm balances the influence of different feature dimensions on the final similarity, for example, automatically increasing the time weight in high update frequency scenarios such as data tables. A dynamic search window strategy based on tree depth is proposed, which reduces the calculation complexity from O(n²) to O(n) while maintaining the accuracy of the algorithm, breaking through the application bottleneck of the DTW algorithm in large-scale data scenarios. A GPU-friendly matrix calculation mode is developed, and WebGL is used to realize real-time parallel calculation in the browser environment. An XPath-based subtree state capture method is designed to completely retain user interaction states (such as scroll position and input box focus) during local re-rendering, improving the continuity of user experience. Combined with MutationObserver API, fine-grained tracking of DOM changes is realized, forming a closed-loop optimization system with the DTW engine.

[0109] Optionally, for compatibility assurance, a progressive enhancement strategy can be adopted to automatically switch the WebGL / WebAssembly calculation backend through browser capability detection, ensuring compatibility with old browsers such as IE11. A React / Vue high-level component package is provided to support the progressive migration of existing projects through custom Hooks (such as useDTW()).

[0110] Optionally, for exception handling, a calculation timeout fuse can be used, specifically when a single calculation exceeds the 20 ms threshold, the system automatically degrades to the traditional Diff algorithm to ensure the functionality availability in extreme scenarios. Memory overflow protection can be used, specifically, memory fragmentation management technology is adopted to strictly limit the memory occupancy of a single page to no more than 50 MB, preventing the risk of crashes on low-end devices.

[0111] Figure 6 A device schematic diagram of a document object model updating processing method provided by an embodiment of the present application is shown in Figure 6 The device includes: An acquisition module 601 is configured to acquire a node sequence of a new document model tree, the node sequence including a plurality of new nodes, each of the new nodes including a hierarchical structure, attributes, styles, and text content. A determination module 602 is configured to determine a priority of each of the new nodes according to the text content of each of the new nodes and an update time difference, the update time difference being used to indicate a time difference between the new document model tree and a current time. The determination module 602 is configured to sequentially traverse each of the new nodes according to the priority of each of the new nodes, and determine a target node matching a current new node from an old document model tree for the current new node. The determination module 602 is configured to determine a multi-dimensional distance between the current new node and the target node, and determine a target update strategy according to the multi-dimensional distance. An update module 603 is configured to update the target node according to the target update strategy and the current new node.

[0112] Optionally, the determination module 602 is specifically configured to: extract key features from the text content of each of the new nodes to obtain a plurality of features corresponding to each of the new nodes, and determine weights of the plurality of features; take the feature with the highest weight corresponding to each of the new nodes as a key feature of each of the new nodes; determine a target weight of each of the new nodes according to a feature value of each of the key features and the update time difference; determine the priority of each of the new nodes according to the size of the target weight of each of the new nodes.

[0113] Optionally, the determination module 602 is specifically configured to: determine fingerprint information of the current new node, the fingerprint information being used to indicate a hierarchical path of the current new node in the new document model tree; perform cross-hierarchical node matching from the old document model tree according to the fingerprint information of the current new node to obtain the target node.

[0114] Optionally, the determination module 602 is specifically configured to: determine semantic similarity, structural similarity, and time sequence proximity between the current new node and the target node; determine the multi-dimensional distance according to the semantic similarity, the structural similarity, and the time sequence proximity.

[0115] Optionally, the determining module 602 is specifically configured to: obtain a new text vector of the current new node, a new node depth, a new sibling node index, an old text vector of the target node, an old node depth, an old sibling node index, an update time difference, and attribute information of the current new node, the attribute information being used to indicate appearance frequency information, depth information, and update frequency information of the current new node; determine the semantic similarity according to the new text vector, the old text vector, and the attribute information of the current new node; determine the structural similarity according to the new node depth, the new sibling node index, the old node depth, the old sibling node index, and the attribute information of the current new node; determine the time sequence proximity according to the update time difference and the attribute information of the current new node.

[0116] Optionally, the determining module 602 is specifically configured to: calculate a cosine similarity between the new text vector and the old text vector; determine whether the current new node is a low-frequency node according to the appearance frequency information in the attribute information; if yes, take a product of the cosine similarity and a first preset value as the semantic similarity; if no, take the cosine similarity as the semantic similarity.

[0117] Optionally, the determining module 602 is specifically configured to: calculate a difference between the new node depth and the old node depth to obtain a depth difference; calculate a difference between the new sibling node index and the old sibling node index to obtain an index difference; determine whether the current new node is a deep-layer node according to the depth information in the attribute information; if yes, determine the structural similarity according to the depth difference, the index difference, a depth proportion value, an index proportion value, and a second preset value; if no, determine the structural similarity according to the depth difference, the index difference, the depth proportion value, and the index proportion value.

[0118] Optionally, the determining module 602 is specifically configured to: if the multi-dimensional distance is less than or equal to a first preset threshold, determine that the target update strategy is an in-place attribute update strategy, the in-place attribute update strategy being used to indicate that a value of the new node is taken as a value of the target node; If the multi-dimensional distance is greater than a first preset threshold and less than a second preset threshold, the target update strategy is determined as a local re-rendering strategy, the second preset threshold is greater than the first preset threshold, and the local re-rendering strategy is used to instruct to redraw the image of the target node as an icon of the new node. If the multi-dimensional distance is greater than or equal to the second preset threshold, the target update strategy is determined as a node reconstruction strategy, and the node reconstruction strategy is used to instruct to replace the target node with the new node.

[0119] Figure 7 A structural block diagram of an electronic device 700 is provided in an embodiment of the present application. As shown in the figure, the electronic device can include a processor 701 and a memory 702. Figure 7

[0120] Optionally, a bus 703 can also be included, wherein the memory 702 is configured to store machine readable instructions executable by the processor 701, and when the electronic device 700 is running, the processor 701 communicates with the memory 702 through the bus 703, and the machine readable instructions are executed by the processor 701 to perform the method steps in the above method embodiments.

[0121] An embodiment of the present application further provides a computer readable storage medium, and the computer readable storage medium stores a computer program, and the computer program is executed by a processor to perform the method steps in the above document object model update processing method embodiments.

[0122] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system and device can refer to the corresponding process in the method embodiments, and will not be repeated in the present application. In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the modules is only a logical function division, and actual implementation can have another division manner. For example, a plurality of modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed elements can be indirect coupling or communication connection through some communication interface, device or module, which can be electrical, mechanical or other forms.

[0123] ​In addition, each function unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. When the functions are realized in the form of software function units and sold or used as an independent product, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application or the parts that essentially contribute to the prior art or the parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.

[0124] The above is only a specific embodiment of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application.

Claims

1. A document object model update processing method, characterized in that, The method includes: Obtain a new document model tree node sequence, the node sequence including multiple new nodes, each new node including hierarchical structure, attributes, styles and text content; The priority of each new node is determined based on its text content and update time difference, wherein the update time difference is used to indicate the time difference between the new document model tree and the current time. According to the priority of each new node, the new nodes are traversed sequentially. For the current new node, the target node that matches the current new node is determined from the old document model tree. Determine the multi-dimensional distance between the current new node and the target node, and determine the target update strategy based on the multi-dimensional distance; The target node is updated according to the target update strategy and the current new node.

2. The document object model update processing method according to claim 1, characterized in that, The step of determining the priority of each new node based on its text content and update time difference includes: Key features are extracted from the text content of each new node to obtain multiple features corresponding to each new node, and the weights of the multiple features are determined. The feature with the highest weight corresponding to each new node is taken as the key feature of each new node; The target weight of each new node is determined based on the feature value of each key feature and the update time difference. The priority of each new node is determined based on the target weight of each new node.

3. The document object model update processing method according to claim 1, characterized in that, Determining the target node that matches the current new node from the old document model tree includes: Determine the fingerprint information of the current new node, the fingerprint information being used to indicate the hierarchical path of the current new node in the new document model tree; The target node is obtained by performing cross-level node matching from the old document model tree based on the fingerprint information of the current new node.

4. The document object model update processing method according to claim 1, characterized in that, Determining the multi-dimensional distance between the current new node and the target node includes: Determine the semantic similarity, structural similarity, and temporal proximity between the current new node and the target node; The multi-dimensional distance is determined based on the semantic similarity, structural similarity, and temporal proximity.

5. The document object model update processing method according to claim 4, characterized in that, Determining the semantic similarity, structural similarity, and temporal proximity between the current new node and the target node includes: Obtain the new text vector, new node depth, and new sibling node index of the current new node; the old text vector, old node depth, and old sibling node index of the target node; the update time difference; and the attribute information of the current new node. The attribute information is used to indicate the occurrence frequency information, depth information, and update frequency information of the current new node. The semantic similarity is determined based on the new text vector, the old text vector, and the attribute information of the current new node; The structural similarity is determined based on the new node depth, the new sibling node index, the old node depth, the old sibling node index, and the attribute information of the current new node. The temporal proximity is determined based on the update time difference and the attribute information of the current new node.

6. The document object model update processing method according to claim 5, characterized in that, Determining the semantic similarity based on the new text vector, the old text vector, and the attribute information of the current new node includes: Calculate the cosine similarity between the new text vector and the old text vector; Determine whether the current new node is a low-frequency node based on the frequency of occurrence information in the attribute information; If yes, the product of the cosine similarity and the first preset value is taken as the semantic similarity; if no, the cosine similarity is taken as the semantic similarity.

7. The document object model update processing method according to claim 5, characterized in that, The step of determining the structural similarity based on the new node depth, the new sibling node index, the old node depth, the old sibling node index, and the attribute information of the current new node includes: Calculate the difference between the depth of the new node and the depth of the old node to obtain the depth difference; Calculate the difference between the index of the new sibling node and the index of the old sibling node to obtain the index difference; Determine whether the current new node is a deep node based on the depth information in the attribute information; If yes, the structural similarity is determined based on the depth difference, index difference, depth ratio value, index ratio value, and the second preset value; if no, the structural similarity is determined based on the depth difference, index difference, depth ratio value, and index ratio value.

8. The document object model update processing method according to claim 1, characterized in that, The step of determining the target update strategy based on the multi-dimensional distance includes: If the multidimensional distance is less than or equal to the first preset threshold, then the target update strategy is determined to be an in-situ attribute update strategy, which is used to indicate that the value of the new node is used as the value of the target node. If the multidimensional distance is greater than a first preset threshold and less than a second preset threshold, then the target update strategy is determined to be a local re-rendering strategy. The second preset threshold is greater than the first preset threshold. The local re-rendering strategy is used to indicate that the image of the target node is redrawn as the icon of the new node. If the multidimensional distance is greater than or equal to the second preset threshold, then the target update strategy is determined to be a node reconstruction strategy, which is used to indicate that the target node is replaced with the new node.

9. An electronic device, characterized in that, The method includes a memory and a processor, wherein the memory stores a computer program executable by the processor, and the processor executes the computer program to implement the steps of the document object model update processing method according to any one of claims 1-8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the document object model update processing method as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Page processing method and device, terminal equipment and readable storage medium

    CN111639287A

  • File information statistics method and device and electronic equipment

    CN114996224A

  • Document data processing method and device, storage medium and computer equipment

    CN120257944A

  • Update notification method and system

    WO2010149026A1

  • Method and system of extracting web page information

    WO2012174137A1