Advertisement
NinjaFighter69696969

XMLjfasjflksaf

Oct 23rd, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. package xmlvalidator;
  2.  
  3. import java.util.regex.*;
  4.  
  5.  
  6. public class Main {
  7.     public static final String bean = "<!-- smuck --> <xml version=\"boodam\"> <person> <firstname>Joe</firstname> <lastname>Walnes</lastname>"
  8.             + "<phone> <code>123</code> <number>1234-456</number> </phone> <fax> <code>123</code>"
  9.             + "<number>9999-999</number> </fax> </person>";
  10.  
  11.  
  12.     public static void main(String[] args) {
  13.         // TODO Auto-generated method stub
  14.         BasicStringStack bob = new BasicStringStack();
  15.        
  16.         Pattern openPat = Pattern.compile("<(?!xml)[^-!/<>]+>");
  17.         Pattern closePat = Pattern.compile("</[^<>]+>");
  18.  
  19.         Matcher openMat = openPat.matcher(bean);
  20.         Matcher closeMat = closePat.matcher(bean);
  21.         // String[] ray = bean.split("\\s+");
  22.         // p(bean.replaceAll("<[^(xml)/<>]+>", " <openTag> "));
  23.         // p(bean.replaceAll("</[^<>]+>", " </closeTag> "));
  24.         while (openMat.find()) {
  25.             p("Found: " + openMat.group());
  26.             bob.push(openMat.group());
  27. //          if(bob.peek(bob.getCount()-1)).equals(anObject)
  28. //          p(bob.getCount());
  29.         }
  30.        
  31.         int c = bob.getCount();
  32.         for(int i = 0; i < c; i++){
  33.             p(i + " " + bob.peek(i));
  34.         }
  35.     }
  36.  
  37.  
  38.     public static <E> void p(E e) {
  39.         System.out.println(e);
  40.     }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement