当前位置: 首页>>代码示例>>Java>>正文


Java XMLEventReader.nextTag方法代码示例

本文整理汇总了Java中javax.xml.stream.XMLEventReader.nextTag方法的典型用法代码示例。如果您正苦于以下问题:Java XMLEventReader.nextTag方法的具体用法?Java XMLEventReader.nextTag怎么用?Java XMLEventReader.nextTag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.stream.XMLEventReader的用法示例。


在下文中一共展示了XMLEventReader.nextTag方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNextTag

import javax.xml.stream.XMLEventReader; //导入方法依赖的package包/类
/**
 * The reason the following call sequence is a problem is that with a
 * peekevent, getElementText calls nextEvent which does properly update the
 * lastEvent
 */
@Test
public void testNextTag() {
    try {
        XMLEventReader er = getReader();
        er.nextTag();
        er.nextTag();

        System.out.println(er.getElementText());
        er.nextTag();
        System.out.println(er.getElementText());

    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:Bug6668115Test.java

示例2: testNextTagWPeek

import javax.xml.stream.XMLEventReader; //导入方法依赖的package包/类
@Test
public void testNextTagWPeek() {
    try {
        XMLEventReader er = getReader();
        er.nextTag();
        er.nextTag();

        er.peek();
        System.out.println(er.getElementText());
        er.nextTag();
        System.out.println(er.getElementText());

    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Bug6668115Test.java

示例3: test

import javax.xml.stream.XMLEventReader; //导入方法依赖的package包/类
@Test
public void test() {
    String xmlData = "<?xml version=\"1.0\"?><Test>Hello</Test>";
    try {
        XMLEventReader xmlReader = XMLInputFactory.newInstance().createXMLEventReader(new ByteArrayInputStream(xmlData.getBytes()));

        XMLEvent event = xmlReader.nextEvent();
        System.out.println(event.getClass());

        // xmlReader.peek(); // error in both cases with/without peek()
        event = xmlReader.nextTag(); // nextEvent() would work fine
        // nextTag() forgets to set fLastEvent
        System.out.println(event.getClass());

        String text = xmlReader.getElementText();
        System.out.println(text);
    } catch (XMLStreamException e) {
        Assert.fail(e.getMessage());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:Bug6586466Test.java

示例4: handleObject

import javax.xml.stream.XMLEventReader; //导入方法依赖的package包/类
private Object handleObject(XMLEventReader parser,
        XMLEvent startEvent,
        ExtensionRegistry extensionRegistry, 
        Message.Builder builder,
        FieldDescriptor field, 
        ExtensionRegistry.ExtensionInfo extension) throws XMLStreamException {

    Message.Builder subBuilder = createSubBuilder(builder, field, extension);

    XMLEvent event = startEvent;
    int depth = 0; // initialize to 0
    do {
        if (event.isStartElement()) {
            depth++; // we're inside the element
            mergeField(parser, event, 
                    extensionRegistry, subBuilder);
            XMLEvent nextEvent = parser.nextTag();
            
            if (nextEvent.isEndElement()) {
                depth--;
                // if we're back under the top level obj, and there is another close, we're done.
                if (depth <= 0 && parser.peek().isEndElement()) {
                    break;
                }
            } else if (nextEvent.isStartElement()) {
                depth++;
            }
        } else {
            // something is potentially wrong..
            break;
        }
    } while (parser.hasNext() && (event = parser.nextTag()) != null);
    
    return subBuilder.build();
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:36,代码来源:XmlJavaxFormat.java

示例5: testNextTag

import javax.xml.stream.XMLEventReader; //导入方法依赖的package包/类
private static void testNextTag(int max)
        throws IOException, XMLStreamException {
    System.out.println("\nTest nextTag (" + max + ")...");
    XMLEventReader reader = createXmlReader(max);
    XMLEvent event;
    do {
        event = reader.nextTag();
        System.out.println(event);
        if (event.getEventType() == XMLEvent.END_ELEMENT
            && event.asEndElement().getName().getLocalPart().equals(ROOT)) {
            break;
        }
    } while (true);
    System.out.println("nextTag passed\n");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:EventFilterSupportTest.java


注:本文中的javax.xml.stream.XMLEventReader.nextTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。