c# - How do you parse multi-level "nodes" in text? -


I have a configuration format similar to * .sln format, so do the following as an example:

  Start the DCOM Productions configuration file, Format Version 1.0Display: Global GlobalKeya = Answeron .: Global Configuration Key :: Store for Applications. This key is used to: Save the current state of the application: as well as to prevent GlobalWeek 3 = AnswerUtvo. See above the secondary key installation GlobalKeyC = AnswerThree BeginSection: UpdateSystem NestedKeyA = A NestedKeyB = 2 NestedKeyC = {A set of multi data, where we will see how to write a multiple paragraph} NestedKeyD = System.Int32, 100 EndSection EndSection BeginSection : Application InstallPath = C: \ Program Files \ DCOM Productions \ BitFlex EndSection  

I know that I need a recursive function that probably takes a segment of text as a parameter so that , For example, will pass an entire section to do this, and Are re-used in parsing this way.

I can not seem around my head to do this. Each section has potentially more child sections like an XML document. I'm not really asking for the code here, just about how to go about parsing such a document, just one method .

I was thinking about using tabs (specifies index) to determine which section I am working with, but if this document did not correctly tab If it was gone, then it will fail. Any better idea?

Perhaps you can draw parallel between this format and XML. That is, BeginSection & LT; ==> "& lt; Inauguration>" EndSection & lt; ==> "& lt; / closing>"

Understand as many XML elements as XML files. What's inside the BeginSection and EndSection, for example NestedKeyA = as "node" and name as "A".

.: A comment is being done with bee and you will have it inside the xml node so that you can leave it. System.Int32, 100 - can be a value of one attribute and one node

{A set of multiple data, where we will see how to write a multi paragraph} - You can check out this algorithm You can also come up with pars to come together.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -