Java XML String Transform createXmlEventReaderOnXmlString(String xml, String docBaseUri)

Here you can find the source of createXmlEventReaderOnXmlString(String xml, String docBaseUri)

Description

create Xml Event Reader On Xml String

License

Open Source License

Declaration

static XMLEventReader createXmlEventReaderOnXmlString(String xml,
            String docBaseUri) throws XMLStreamException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLInputFactory;

import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;

import java.io.Reader;
import java.io.StringReader;

public class Main {
    static XMLEventReader createXmlEventReaderOnXmlString(String xml,
            String docBaseUri) throws XMLStreamException {
        Reader stringReader = new StringReader(xml);
        Source source = new StreamSource(stringReader,
                docBaseUri.toString());/*from w  ww  .  j a  v  a  2s .  co m*/
        XMLInputFactory factory = XMLInputFactory.newInstance();
        factory.setProperty("javax.xml.stream.isCoalescing", Boolean.TRUE);
        factory.setProperty("javax.xml.stream.supportDTD", Boolean.FALSE);

        return factory.createXMLEventReader(source);
    }
}

Related

  1. createSource(final String message)
  2. createSource(String msg)
  3. createString(Element element)
  4. createXml(ArrayList nameList, ArrayList stringList, ArrayList stringArrayNameList, HashMap> stringArrayContentMap)
  5. createXmlError(String message, String details)
  6. decodeHex(String hex)
  7. elementToXMLString(Object aElement)
  8. encode(final String value)
  9. encodeStringIntoMemento(String str)