开发者

Check whether a particular child exists or not in some root

开发者 https://www.devze.com 2023-03-19 20:03 出处:网络
I am parsing an xml through DOM parser and I have to check that whether a partcular child exists or not in the xml. For example

I am parsing an xml through DOM parser and I have to check that whether a partcular child exists or not in the xml. For example

 <Employee>
      <Emp>
         <Name>          A     </Name>
         <Designation>   C     </Designation>
         <Experience>    D     </Experience>
     </Emp>
      <Emp>
         <Name>          x     </Name>
         <Designation>   y     </Designation>   
     </Emp>

</Employee>

and so on...As you can see "experience" tag is present for some employees and may not be present for other. How I can check wheth开发者_开发知识库er Experience tag is present for any employee or not. Any help is appreciated.


Well this thing can be checked.You can write a piece of code to check this tag is present or not.In case of tag not present you can return some value may be null.

if([elementName isEqualToString:@"emp"])
        {
            attributeOfColoumn = [attributeDict objectForKey:@"Experience"];
            if([attributeOfColoumn isEqualToString:@""])
            {
            return yes;
            }
    }
0

精彩评论

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