Validar xml

1 resposta
I
estou seguindo um tutorial para validação de um xml, mas da erro segue cod. e erro.....
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(false);
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document docs = builder.parse(new File(arquivoXML));
        NodeList elements = docs.getElementsByTagName(tag);
        Element el = (Element) elements.item(0);
        String id = el.getAttributes("Id");    erro aqui no getAttribute!!

erro..

method getAttributes in interface Element cannot be applied to given types;
required: no arguments
found: String
reason: actual and formal argument lists differ in length

grato pela ajuda!!

1 Resposta

yurifw

ele ta falando q esse metodo n tem nenhum argumento e vc ta passando uma String. Eu acho q vc se confundiu e ta usando o metodo getAttributes por engano, quando deveria ser getAttribute (repare no ‘S’) xD

Criado 7 de junho de 2013
Ultima resposta 7 de jun. de 2013
Respostas 1
Participantes 2