-
-
Notifications
You must be signed in to change notification settings - Fork 488
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
parse yaml file VB,net #940
Comments
The children property is of type
|
This is working code that dumps out the key Dim YamlData As String = "hello: world"
Dim inputYaml = New StringReader(YamlData)
Dim yamled = New YamlStream()
yamled.Load(inputYaml)
' Examine the stream
Dim mappings As YamlMappingNode = CType(yamled.Documents(0).RootNode, YamlMappingNode)
For Each entry In mappings.Children
Console.WriteLine(CType(entry.Key, YamlScalarNode).Value)
Next Results in
|
Thanks for the help Edward! That's what I have but "entry" is still not defined correctly. I have yamldotnet installed from GitHub and have it declared as an import but VS has "entry" flagged as undefined. I'm missing something. |
That was a copy paste of the entire application. Can you put up a repo with the minimum amount of code required to reproduce it? |
I pasted your code into a new application and loaded yaldotnet 16.0 and entry did not trigger an error. That was helpful and lead me to figure out the problem. In the application I am using yamldotnet, I have Option Explicit On which means that all variables must be declared. So the "For Each entry In" is not declared explicitly. When I turn Option Explicit Off, the error goes away. This proves what I thought was wrong originally that the "entry" needs to be declared. My "For Each" syntax looks like "For Each row as DataRow in test.datatable.rows". I just don't know how to declare entry. |
The data type should be |
OK, that worked. Here's how it looks in VB.net For Each entry As KeyValuePair(Of YamlNode, YamlNode) In mappings.Children |
Thanks for your help! I have another question. I am able to view the content of a yaml file but how do I take the content I write to the console and save it to another yaml file to make a duplicate? Here's my code to view the content: Dim ContentYaml As String = File.ReadAllText("C:\original.yaml") |
Hello, I'm trying to view all the contents of a yaml file but I'm having trouble converting the sample code from C# to VB.net. Visual Studio gives an error in this code at the "For each key" line stating that 'key' is not declared but I'm not sure what I need to declare it to. Thanks for your help!
Dim YamlData As String = File.ReadAllText(System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "" & "filter.yaml")
Dim inputYaml = New StringReader(YamlData)
Dim yamled = New YamlStream()
yamled.Load(inputYaml)
' Examine the stream
Dim mappings As YamlMappingNode = CType(yamled.Documents(0).RootNode, YamlMappingNode)
For Each key In mappings.Children
Console.WriteLine(CType(entry.Key, YamlScalarNode).Value)
Next
The text was updated successfully, but these errors were encountered: