Buenas soy nuevoaqui
Os digo mi duda
tengo el siguiente xml:
<?xml version="1.0" encoding="us-ascii"?><SWIFT_ERROR MessageType="515"><BreValidationError MessageType="" ErrorCode="T73"><ElementName Name="CountryCode" /><SequenceName Name="" /><ElementValue Value="TY" /><RuleName Name="Validate_MT515" /><PolicyName Name="CountryCode_Policy" /><ConditionalRuleName RuleName="" /><ConditionalRuleNumber RuleNumber="" /><ErrorMessage Message="Country code not valid. Refer to BIC Directory General Information - Country Codes." /></BreValidationError><BreValidationError MessageType="" ErrorCode="T73"><ElementName Name="CountryCode" /><SequenceName Name="" /><ElementValue Value="TY" /><RuleName Name="Validate_MT515" /><PolicyName Name="CountryCode_Policy" /><ConditionalRuleName RuleName="" /><ConditionalRuleNumber RuleNumber="" /><ErrorMessage Message="Country code not valid. Refer to BIC Directory General Information - Country Codes." /></BreValidationError><BreValidationError MessageType="" ErrorCode="T73"><ElementName Name="CountryCode" /><SequenceName Name="" /><ElementValue Value="TY" /><RuleName Name="Validate_MT515" /><PolicyName Name="CountryCode_Policy" /><ConditionalRuleName RuleName="" /><ConditionalRuleNumber RuleNumber="" /><ErrorMessage Message="Country code not valid. Refer to BIC Directory General Information - Country Codes." /></BreValidationError><BreValidationError MessageType="MT515" ErrorCode="E84"><ElementName Name="" /><SequenceName Name="" /><ElementValue Value="" /><RuleName Name="Validate_MT515" /><PolicyName Name="SWIFT_NetworkRule284_Policy" /><ConditionalRuleName RuleName="C4" /><ConditionalRuleNumber RuleNumber="Rule 284" /><ErrorMessage Message="" /></BreValidationError><BreValidationError MessageType="MT515" ErrorCode="E84"><ElementName Name="" /><SequenceName Name="" /><ElementValue Value="" /><RuleName Name="Validate_MT515" /><PolicyName Name="SWIFT_NetworkRule284_Policy" /><ConditionalRuleName RuleName="C4" /><ConditionalRuleNumber RuleNumber="Rule 284" /><ErrorMessage Message="" /></BreValidationError></SWIFT_ERROR>
y quiero guardar los valores que hay entre comillas de ErrorCode, Message y RuleName.
mediante el siguiente codigo Java
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(new InputSource(new StringReader(msjError.getData().toString())));//msjError es el nombre del xml
//REGLAS
Element rootElement = document.getDocumentElement();
NodeList reglaValidation = rootElement.getElementsByTagName(BREVALIDATIONERRO R);
int longitud = reglaValidation.getLength();
for (int i=INT_CERO; i<longitud; i++){//Recuperamos los valores los TAG ErrorCode, Message y Rule Name
Element elemento = (Element) reglaValidation.item(i);
if (elemento.hasAttribute(ERRORCODE)){
String ValorErrorCode = elemento.getAttribute(ERRORCODE).toString();
}
}
Consiguie recuperar el valor entre comillas(ej. "T73") que hay en ErrorCode, pero no se como conseguir los de Message y RuleName.
Si me ayudais os lo agradeceria.
Un saludo.