Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method for getting xml node as RawString. #16

Merged
merged 2 commits into from
Mar 15, 2022

Conversation

ikorin24
Copy link
Owner

@ikorin24 ikorin24 commented Mar 6, 2022

Added method(s)

  • in U8Xml.XmlNode
    • public RawString AsRawString()

How it works

const string XmlString =
@"<?xml version='1.0' ?>
<a>
  <b>
    <c>foo</c>
  </b>
</a>";


using XmlObject xml = XmlParser.Parse(XmlString);
XmlNode nodeA = xml.Root;              // <a>...</a>
XmlNode nodeB = nodeA.FindChild("b");  // <b>...</b>

RawString nodeString = nodeB.AsRawString();
Console.WriteLine(nodeString);

The output is

<b>
    <c>foo</c>
  </b>

NOTE

The indent of the node is ignored at the head.

@ikorin24
Copy link
Owner Author

ikorin24 commented Mar 6, 2022

close #15

@simon-curtis
Copy link

🥳 thanks!

@ikorin24 ikorin24 merged commit 9a115b6 into master Mar 15, 2022
@ikorin24 ikorin24 deleted the feature/node-string branch March 15, 2022 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants