Check if config file contains children elements

Discussion in 'Plugin Development' started by Weasel_Squeezer, May 23, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Weasel_Squeezer

    ok so my problem is that I need to be able to check some of my YAML data files to see if any children of certain elements or paths exist without knowing the names of the children elements. Below is my current example YAML.
    Code:
    root:
      userdefined:
        value: 'blah blah blah'
        upgrade-1:
          value: 'blah asdf asdf'
        upgrade-2:
          value: 'blah asdf asdf'
    The child element that I need to check if it exists is the child of the "userdefined" parent element which is the "upgrade-#" element. The "upgrade-" text will always be that, but the number is user defined and can be any number. The number just defines its spot in a sort of ranking ladder.
    Anyway, I do not want to have to loop through thousands of numbers to see if "upgrade-" + # exists. And I cannot use the config.contains(path) method because I need to know the specific and exact path name.
    Is there any solution to this without using and InputStreamReader or some other Java file reading classes?

    EDIT: also be able to get the values of the children elements with unknown names
     
  2. Offline

    Jogy34

    I don't know if there is an easy way to do this without having to iterate through the entire file manually but when I've needed to do something like that for my plugins I had a list before hand that would have all of the subvalues in it so that you can just look there to get what you want.
     
Thread Status:
Not open for further replies.

Share This Page