0

I have multiple XMLs just varies tag names like this

sample1.xml

<Customer>
   <ns1:Account>
</Customer>

sample2.xml

<Customer>
   <ns3:Account>
</Customer>

sample3.xml

<Customer>
   <ns5:Account>
</Customer>

Account tag is constant but ns value is changing is each xml file. I want to give a regular expression inside doc.getElementsByTagName method like ".*child" to write a generic xml function using java xml parser but it is not working. Please help.

         File inputFile = new File("input.txt");
         DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
         DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
         Document doc = dBuilder.parse(inputFile);
         NodeList nList = doc.getElementsByTagName(".*Account");  // giving me null
2
  • See this question as well. Commented Jan 15, 2021 at 17:43
  • Thanks, @FedericoklezCulloca. I've added it to the duplicate link list. Commented Jan 15, 2021 at 17:58

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.