NanoXLSX.Core 3.1.0
Loading...
Searching...
No Matches
XmlStreamUtils.cs
1/*
2 * NanoXLSX is a small .NET library to generate and read XLSX (Microsoft Excel 2007 or newer) files in an easy and native way
3 * Copyright Raphael Stoeckli © 2026
4 * This library is licensed under the MIT License.
5 * You find a copy of the license in project folder or on: http://opensource.org/licenses/MIT
6 */
7
8using System;
9using System.Xml;
10
11namespace NanoXLSX.Utils.Xml
12{
17 public static class XmlStreamUtils
18 {
23 public static XmlReaderSettings CreateSettings()
24 {
25 return new XmlReaderSettings
26 {
27 XmlResolver = null,
28 IgnoreWhitespace = true,
29 IgnoreComments = true,
30 IgnoreProcessingInstructions = true,
31 };
32 }
33
38 public static bool IsElement(XmlReader reader, string localName)
39 {
40 return reader.NodeType == XmlNodeType.Element
41 && reader.LocalName.Equals(localName, StringComparison.OrdinalIgnoreCase);
42 }
43
49 public static string ReadElementText(XmlReader reader)
50 {
51 if (reader.IsEmptyElement)
52 {
53 return string.Empty;
54 }
55 return reader.ReadElementContentAsString();
56 }
57 }
58}
Static utility class providing helpers for forward-only XmlReader-based (SAX-style) parsing,...
static string ReadElementText(XmlReader reader)
Reads the string content of a simple leaf element (one that contains only text, no child elements)....
static bool IsElement(XmlReader reader, string localName)
Returns true when the reader is positioned on a start element whose LocalName matches localName (Ord...
static XmlReaderSettings CreateSettings()
Creates standardized XmlReaderSettings for all reader plug-ins: XmlResolver=null (security),...