From ad37b8e2bd9dbe5bc1c5e3934af105da5c27a694 Mon Sep 17 00:00:00 2001 From: 0MG-DEN Date: Wed, 6 May 2026 23:41:02 +0300 Subject: [PATCH] Write text in SAX samples --- samples/spreadsheet/copy_worksheet_with_sax/cs/Program.cs | 7 +++++++ samples/spreadsheet/copy_worksheet_with_sax/vb/Program.vb | 2 ++ samples/word/replace_text_with_sax/cs/Program.cs | 8 +++++++- samples/word/replace_text_with_sax/vb/Program.vb | 2 ++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/samples/spreadsheet/copy_worksheet_with_sax/cs/Program.cs b/samples/spreadsheet/copy_worksheet_with_sax/cs/Program.cs index dd43c0d..2b93f0c 100644 --- a/samples/spreadsheet/copy_worksheet_with_sax/cs/Program.cs +++ b/samples/spreadsheet/copy_worksheet_with_sax/cs/Program.cs @@ -111,6 +111,13 @@ void CopySheetSAX(string path) if (reader.IsStartElement) { writer.WriteStartElement(reader); + + string text = reader.GetText(); + + if (text.Length > 0) + { + writer.WriteString(text); + } } else if (reader.IsEndElement) { diff --git a/samples/spreadsheet/copy_worksheet_with_sax/vb/Program.vb b/samples/spreadsheet/copy_worksheet_with_sax/vb/Program.vb index 481848a..c57b03b 100644 --- a/samples/spreadsheet/copy_worksheet_with_sax/vb/Program.vb +++ b/samples/spreadsheet/copy_worksheet_with_sax/vb/Program.vb @@ -100,6 +100,8 @@ Module Program Else If reader.IsStartElement Then writer.WriteStartElement(reader) + Dim text As String = reader.GetText() + If text.Length > 0 Then writer.WriteString(text) ElseIf reader.IsEndElement Then writer.WriteEndElement() End If diff --git a/samples/word/replace_text_with_sax/cs/Program.cs b/samples/word/replace_text_with_sax/cs/Program.cs index a1206f2..9b442d5 100644 --- a/samples/word/replace_text_with_sax/cs/Program.cs +++ b/samples/word/replace_text_with_sax/cs/Program.cs @@ -46,7 +46,6 @@ void ReplaceTextWithSAX(string path, string textToReplace, string replacementTex string text = reader.GetText().Replace(textToReplace, replacementText); writer.WriteString(text); - } else { @@ -60,6 +59,13 @@ void ReplaceTextWithSAX(string path, string textToReplace, string replacementTex if (reader.IsStartElement) { writer.WriteStartElement(reader); + + string text = reader.GetText(); + + if (text.Length > 0) + { + writer.WriteString(text); + } } else if (reader.IsEndElement) { diff --git a/samples/word/replace_text_with_sax/vb/Program.vb b/samples/word/replace_text_with_sax/vb/Program.vb index 5190879..23339a1 100644 --- a/samples/word/replace_text_with_sax/vb/Program.vb +++ b/samples/word/replace_text_with_sax/vb/Program.vb @@ -49,6 +49,8 @@ Module Program ' Write the other XML elements without editing If reader.IsStartElement Then writer.WriteStartElement(reader) + Dim text As String = reader.GetText() + If text.Length > 0 Then writer.WriteString(text) ElseIf reader.IsEndElement Then writer.WriteEndElement() End If