Skip to content

Commit cda8832

Browse files
author
Dmitry Ovsyanko
committed
chapter_02 FIX
1 parent 7228a09 commit cda8832

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

doc_src/src/chapter_02.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async function processLargeFile(filepath) {
4242

4343
for await (const node of reader) {
4444
if (node.localName === 'product' && node.attributes.id === '101') {
45-
console.log(await node.getTextContent());
45+
console.log(node.innerText);
4646
break; // Early exit possible
4747
}
4848
}
@@ -106,7 +106,7 @@ Whether produced by `XMLParser` or yielded by `XMLReader`, an `XMLNode` represen
106106
attributes: AttributesMap, // Map-like object for attribute access
107107
namespaces: NamespacesMap, // In-scope namespace declarations
108108
children: [XMLNode], // Child nodes (for element types)
109-
textContent: string, // Concatenated text of all child text nodes
109+
innerText: string, // Concatenated text of all child text nodes
110110
parent: XMLNode | null // Reference to parent (may be null in streaming)
111111
}
112112
```
@@ -121,7 +121,7 @@ const priceNode = doc.children.find(c => c.localName === 'price');
121121
const currency = priceNode?.attributes?.currency ?? 'USD';
122122

123123
// Get text content
124-
const amount = priceNode?.textContent?.trim();
124+
const amount = priceNode?.innerText;
125125
```
126126
127127
In streaming mode (`XMLReader`), the `parent` reference may be `null` for performance reasons, and `children` may be empty if you have not configured the reader to collect them. Always check the reader's configuration when relying on tree structure.

0 commit comments

Comments
 (0)