using Regular Expression cheak xml tag

I have A xml File Where I have to Search <correspondenceTo>(.*?)</correspondenceTo>,if This tag is There Then we have to find in bettween <email> tag and cheak <Email> have in this format or not,<email>:&#x000A0;<email>,if not throw error

public void checkEntityTag(XMLContext xmlContext)throws Exception
                  {

                       System.out.println("journal name is"+CheckContent1.getFilePath());
                       File file=new File(CheckContent1.getFilePath());
                       BufferedReader b=new BufferedReader(new FileReader(file));
                       String readLine = "";
                        System.out.println("Testing checkEntityTag ");
                          Pattern  pat= Pattern.compile("<correspondenceTo>(.*?)</correspondenceTo>",Pattern.DOTALL);
                         while ((readLine = b.readLine()) != null) {
                                Matcher m=pat.matcher(readLine);
                    
                          if(m.find())
                           {
                               if(m.group().contains("<email>:&#x000A0;<email>"))
                               {
                	    System.out.println("pass");
                               }
                           }
                        else
                     {
                	System.out.println(" Non Breakable Entity is missing in between Word \"+\"\\\"email\\\"\"+ \"and tag\" +\"\\\"&lt;email&gt;\\");
                }
            }

Open in new window

LVL 1
manoj kumarAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Which xml api are you using? i.e. where does this method come from?

public void checkEntityTag(XMLContext xmlContext)throws Exception

Open in new window

manoj kumarAuthor Commented:
we are using don parser,and the method come from other class to cheak some rule in xml file.so condition is  pat= Pattern.compile("<correspondenceTo>(.*?)</correspondenceTo>");  and i am giving one xml file as input,if in xml file it contains <correspondenceTo> tag ,after finding it cheak the condition m.group(1).contains("<EMAIL>:&#x000A0;</EMAIL>")) if it is there then match pass else fail is there, while ((strLine = b.readLine()) != null) { { // System.out.println(strLine); Matcher m = pat.matcher(strLine); while(m.find()) { //System.out.println(m.group(0)); if(m.group(1).contains("<EMAIL>:&#x000A0;</EMAIL>")) { System.out.println("match pass"); } else { System.out.println("Error is there:Please Specify Email Tag as <EMAIL>:&#x000A0;</EMAIL> "); } } }
manoj kumarAuthor Commented:
Dom parser

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
manoj kumarAuthor Commented:
completed
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.