Created
December 19, 2014 08:05
-
-
Save shomah4a/70bbf4214991b760d3fa to your computer and use it in GitHub Desktop.
ほっけ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File; | |
import javax.xml.parsers.SAXParserFactory; | |
import javax.xml.parsers.SAXParser; | |
import org.xml.sax.Attributes; | |
import org.xml.sax.helpers.DefaultHandler; | |
public class Hokke | |
{ | |
static class Handler extends DefaultHandler | |
{ | |
public void startElement(String uri, | |
String localName, | |
String qName, | |
Attributes attributes) | |
{ | |
System.out.println("attribute: " + attributes.getValue("hokke")); | |
} | |
public void characters(char[] ch, | |
int offset, | |
int length) | |
{ | |
System.out.println("text: " + new String(ch, offset, length)); | |
} | |
} | |
public static void main(String[] args) throws Exception | |
{ | |
SAXParserFactory factory = SAXParserFactory.newInstance(); | |
SAXParser parser = factory.newSAXParser(); | |
parser.parse(new File("hokke.xml"), new Handler()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--*- coding:utf-8 -*--> | |
<xml> | |
<hoge hokke="𩸽">𩸽</hoge> | |
<hoge hokke="𩸽">𩸽</hoge> | |
<hoge hokke="𩸽">𩸽</hoge> | |
<hoge hokke="𩸽">𩸽</hoge> | |
</xml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ java Hokke | |
attribute: null | |
text: | |
attribute: 𩸽 | |
text: 𩸽 | |
text: | |
attribute: 𩸽𩸽 | |
text: 𩸽 | |
text: | |
attribute: 𩸽𩸽𩸽 | |
text: 𩸽 | |
text: | |
attribute: 𩸽𩸽𩸽𩸽 | |
text: 𩸽 | |
text: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment