开发者

checking checkbox.name during xml parsing so that i do not duplicate a checkbox

开发者 https://www.devze.com 2023-02-14 19:18 出处:网络
I need to parse a xml document with many elements with their element\'s attribute value to create new checkbox with the attribute value as the name of the checkbox. In my application I\'ve already har

I need to parse a xml document with many elements with their element's attribute value to create new checkbox with the attribute value as the name of the checkbox. In my application I've already hard coded some of these attribute value into checkboxes. Therefore my question is, is there a way for me to check if these have already been created? If yes, I will not do anything. If no, I will then create ne开发者_如何学运维w checkbox.

Here is an example of an XML document to be parsed:

<target name="number1" if="nameofcheckbox1">
...
</target>
<target name="number2" if="nameofcheckbox2">
...
</target>

In the above example, I've already hard coded a checkbox and called it: nameofcheckbox1CheckBox. Then i will parse this document and new checkbox will be created for the "number2". It will be called nameofcheckbox2CheckBox. Hence, I will need something here to make sure that i do not duplicate another checkbox called nameofcheckbox1CheckBox. Many thanks


bool checkbox1Exists = ControlExists("nameofcheckbox1");
bool checkbox2Exists = ControlExists("nameofcheckbox2");

private bool ControlExists(string name)
{
    return FindName(name) != null;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消