I’m parsing this document: http://greenmoss.dk/recipe01.xml and going through each element and saving the data. But I’m unable to find this element:
ingList id=”1″
I’ve tried this:
//--------ING-List--------
else if ([elementName isEqualToString:@"ingList id=\"1\""])
{
NSLog(@"ING-LIST HERE!!!!", nil);
}
and tried this:
//--------ING-List--------
else if ([elementName isEqualToString:@"ingList"])
{
NSLog(@"INGLIST HERE!!!!", nil);
}
How do I locate that element?
It makes sense that the first would fail and the second would succeed. In:
The element name is “ingList”. This element also has one attribute; this attribute’s name is “id” and its value is “1”.
Because the element name is just “ingList”,
[elementName isEqualToString:@"ingList"]will succeed, but[elementName isEqualToString:@"ingList id=\"1\"]will fail because id=”1″ is not part of the element name.In order to get this to work, you’ll have to first check if the element name is “ingList” (which you can already do). If it is, you’ll have to get the attributes from that element, determine if one of them has the name “id”, and if that attribute’s value is “1”.
Unfortunately, I don’t know what language you are using or what XML library is being used, so I can’t fill in the details of determining attribute values.
Edit: Looking around, it looks like your inner test could be something along the lines of the following, but like I said, I don’t have experience with this so the code could be wrong.