update data in java class as per change in attribute in the xml file

后端 未结 2 1714
说谎
说谎 2020-12-21 22:36

I want to add an attribute to the xml defination file

Now i want this change to be reflected in a java class . Can you suggest as to how it can be done . Also i w

2条回答
  •  醉梦人生
    2020-12-21 23:00

    Try to implement using this code

    your attribute.xml

    
        
                
                    riddhish
                chaudhari
            
        
    
    

    Class File

    public static final String ATTRIBUTE_LIST = "ATTRIBUTE_LIST";
    public static final String ATTRIBUTE = "ATTRIBUTE";
    public static final String FNAME = "FNAME";
    

    Code for rading attributes from xml file

    Document document = null;
    NodeList nodeList = null;
    Node node = null;
    
    nodeList = document.getElementsByTagName("----file attributes.xml---").item(0).getChildNodes();
    HashMap  localParameterMap  = new HashMap();
    
    for(int i=0; i

    function() readAttributeList

    private Collection readAttributeList(Node node){
        Collection objCollection = new ArrayList();
        NodeList nodeList = node.getChildNodes();   
    
        for(int i=0; i < nodeList.getLength(); i++){
            Node subNode = nodeList.item(i);
    
            if(subNode.getNodeName().equals("attribute")){
                NodeList attributeList = subNode.getChildNodes();
                HashMap  attributeMap  = new HashMap();
    
                    for(int j=0; j
    
    

    for reading attribute values in variable

    String strfname = null;
    
    if(map.get(CLASS_NAME.FNAME) != null) {
        strfname = (String)map.get(CLASS_NAME.FNAME);
    }
    

    提交回复
    热议问题