Skip to content

Commit

Permalink
Add apostrophe support for attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBang1112 committed Dec 31, 2024
1 parent b988418 commit 70ac2ea
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions MinimalXmlReader/MiniXmlReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,21 @@ private Dictionary<string, string> ReadAttributes(bool expectsProcessingInstruct

Advance();

var isApostrophe = false;

if (!SkipChar('"'))
{
throw new Exception("Expected \"");
if (SkipChar('\''))
{
isApostrophe = true;
}
else
{
throw new Exception("Expected \" or '");
}
}

var attValue = ReadUntilChar('"', includeSpaces: true);
var attValue = ReadUntilChar(isApostrophe ? '\'' : '"', includeSpaces: true);

Advance();

Expand Down Expand Up @@ -407,12 +416,21 @@ private void SkipAttributes(bool expectsProcessingInstruction = false)

Advance();

var isApostrophe = false;

if (!SkipChar('"'))
{
throw new Exception("Expected \"");
if (SkipChar('\''))
{
isApostrophe = true;
}
else
{
throw new Exception("Expected \" or '");
}
}

SkipUntilChar('"', includeSpaces: true);
SkipUntilChar(isApostrophe ? '\'' : '"', includeSpaces: true);

Advance();

Expand Down

0 comments on commit 70ac2ea

Please sign in to comment.