I am creating a helper class when parsing XML elements, so the developer does not need to know the exact name and capitalization of the XML fields.
private static class TagNames{
public static String RESOURCE_ID = "ResourceId";
public static String RESOURCE_NAME = "ResourceName";
public static String RESOURCE_PRICE = "ResourcePrice";
}
This facilitates the implementation of actions such as:
someXMLParser.getValueByTagName(TagNames.RESOURCE_ID);
My question is that. If I want to iterate over all fields declared in the TagNames class, how to do this? Pseudocode:
For tag in TagNames:
someXMLParser.getValueByTagName(tag)
I know that I will probably have to rebuild all of this. But I cannot figure out how to make names easily accessible, as well as iterative, without any duplication.
Any suggestions?
source
share