Question about speed of findAllElements #116
-
I need to find only first matched element. Now I am doing it:
But my XML docs are very big, and I suppose that |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
Yes, check out the event-driven API: https://github.com/renggli/dart-xml#event-driven Note: |
Beta Was this translation helpful? Give feedback.
-
@renggli thanks!
|
Beta Was this translation helpful? Give feedback.
-
This code is from example. I tried to do:
But it does not find tag value |
Beta Was this translation helpful? Give feedback.
-
Regarding #113 (comment): This is not using a Regarding #113 (comment): You seem to miss the import of the XML library, the |
Beta Was this translation helpful? Give feedback.
-
And analyzer show that node is list, not single node: So only: |
Beta Was this translation helpful? Give feedback.
-
It's seems that this code are work:
Only question is |
Beta Was this translation helpful? Give feedback.
-
In result I wrote next code.
It this code is ok? It's working. But maybe I should add any interruption/break? I need to find only first match. I do not need full scan of document. |
Beta Was this translation helpful? Give feedback.
-
You are right, before the |
Beta Was this translation helpful? Give feedback.
-
For the rest have a look at Dart tutorials on Streams, finding the first element of a stream is a standard operation unrelated to this library. |
Beta Was this translation helpful? Give feedback.
Yes, check out the event-driven API: https://github.com/renggli/dart-xml#event-driven
Note:
findAllElements
is not slow. What is not efficient is to read gigabytes of text and to build a DOM with millions of objects that are not used in the end. With the event-driven API you can avoid that and incrementally scan through the input only building and keeping the parts of the tree in memory that you actually need.