/*
(non-Javadoc)
@see com.popbill.api.HTTaxinvoiceService#GetXML(java.lang.String, java.lang.String)
499612
@Override
	public HTTaxinvoiceXMLResponse getXML(String CorpNum, String NTSConfirmNum)
			throws PopbillException {
		return getXML(CorpNum, NTSConfirmNum, null);
	}
475018
public static String formatXml(String xml) {
    assertInitialization();
    return XLog.sLogConfiguration.xmlFormatter.format(xml);
  }
702661
@Deprecated
    public static String formatXml(String xml){
        try{
           Transformer serializer= SAXTransformerFactory.newInstance().newTransformer();
           serializer.setOutputProperty(OutputKeys.INDENT, "yes");         
           serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
           Source xmlSource=new SAXSource(new InputSource(new ByteArrayInputStream(xml.getBytes())));
           StreamResult res =  new StreamResult(new ByteArrayOutputStream());            
           serializer.transform(xmlSource, res);
           return new String(((ByteArrayOutputStream)res.getOutputStream()).toByteArray());
        }catch(Exception e){   
           return xml;
        }
     }
1176592
@SuppressWarnings("unchecked")
    public <T> T fromXml(String xml, boolean caseSensitive) {
        try {
            String fromXml = xml;
            if (!caseSensitive)
                fromXml = xml.toLowerCase();
            StringReader reader = new StringReader(fromXml);
            return (T) createUnmarshaller().unmarshal(reader);
        } catch (JAXBException e) {
            throw new RuntimeException(e);
        }
    }
1176639
public T fromXML(String xml) throws Exception {
    Unmarshaller u = this.getUnmarshaller();
    u.setProperty(MarshallerProperties.MEDIA_TYPE, "application/xml");
    T result = this.fromString(u, xml);
    return result;
  }
107941
public static Document convertXMLToDOM(String strXML)
    {
        DocumentBuilder db = Util.getDocumentBuilder();
        // Parse the input file
        Document doc = null;
        try {
            synchronized (db)
            {   // db is not thread safe
                doc = db.parse(new InputSource(new StringReader(strXML)));
            }
        } catch (SAXException se) {
            System.out.println(se.getMessage());
            return null;
        } catch (IOException ioe) {
            System.out.println(ioe);
            return null;
        } catch (Exception ioe) {
            System.out.println(ioe);
            return null;
        }
        return doc;
    }
147589
def getXmlText (parent, tag):
    """"""
    elem = parent.getElementsByTagName(tag)[0]
    # Yes, the DOM standard is awful.
    rc = []
    for node in elem.childNodes:
        if node.nodeType == node.TEXT_NODE:
            rc.append(node.data)
    return ''.join(rc)
1006766
protected function getXmlString()
    {
        $xml = '<?xml version="1.0" encoding="UTF-8"?>
                <ccPostAuthRequestV1
                    xmlns="http://www.optimalpayments.com/creditcard/xmlschema/v1"
                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                    xsi:schemaLocation="http://www.optimalpayments.com/creditcard/xmlschema/v1" />';

        $sxml = new \SimpleXMLElement($xml);

        $merchantAccount = $sxml->addChild('merchantAccount');

        $merchantAccount->addChild('accountNum', $this->getAccountNumber());
        $merchantAccount->addChild('storeID', $this->getStoreId());
        $merchantAccount->addChild('storePwd', $this->getStorePassword());

        $sxml->addChild('confirmationNumber', $this->getTransactionReference());
        $sxml->addChild('merchantRefNum', $this->getCustomerId());
        $sxml->addChild('amount', $this->getAmount());

        return $sxml->asXML();
    }
940704
public static Api fromXML(final String xml) throws Exception {
  	Api result=null;
  	try {
  	  result=apifactory.fromXML(xml);
  	} catch (JAXBException je) {
  		LOGGER.log(Level.SEVERE,je.getMessage());
  		LOGGER.log(Level.INFO,xml);
  		throw je;
  	}
    return result;
  }
1169364
public String toXML()
    {
        String eol = System.getProperty("line.separator");
        RepositoryTags tags = RepositoryTags.getInstance();

        // The result
        String result = "     ";

        switch (this.fieldSource)
        {
            case SOURCE_FIELD :
                result += " " + tags.getOpeningTagNonClosingById(RUNTIME_ARGUMENT);
                result += " " + tags.getAttribute(FIELD_REF, this.fieldRefName);
                result += " " + tags.getAttribute(RETURN, String.valueOf(this.returnedByProcedure));
                result += "/>";
                break;
            case SOURCE_VALUE :
                result += " " + tags.getOpeningTagNonClosingById(CONSTANT_ARGUMENT);
                result += " " + tags.getAttribute(VALUE, this.constantValue);
                result += "/>";
                break;
            case SOURCE_NULL :
                result += " " + tags.getOpeningTagNonClosingById(RUNTIME_ARGUMENT);
                result += "/>";
                break;
            default :
                break;
        }

        // Return the result.
        return (result + eol);
    }
1280139
@SuppressWarnings("unchecked")
  public static <T> T fromXml(Class<T> clazz, String xml) {
    T object = (T) CLASS_2_XSTREAM_INSTANCE.get(clazz).fromXML(xml);
    return object;
  }
323360
public static String getFormatFromXmlFile(File xmlFile) {
        if (xmlFile == null || !xmlFile.exists())
            return null;

        try (Reader reader = createReader(xmlFile)) {
            return getFormatFromXmlReader(reader);
        }
        catch (IOException | RuntimeException e) {
            return null;
        }
    }
564688
@Override
    public final String getElementText() throws XMLStreamException {
        XMLEvent event = this.previousEvent;
        if (event == null) {
            throw new XMLStreamException(
                    "Must be on START_ELEMENT to read next text, element was null");
        }
        if (!event.isStartElement()) {
            throw new XMLStreamException(
                    "Must be on START_ELEMENT to read next text", event.getLocation());
        }

        final StringBuilder text = new StringBuilder();
        while (!event.isEndDocument()) {
            switch (event.getEventType()) {
                case XMLStreamConstants.CHARACTERS:
                case XMLStreamConstants.SPACE:
                case XMLStreamConstants.CDATA:
                    {
                        final Characters characters = event.asCharacters();
                        text.append(characters.getData());
                        break;
                    }
                case XMLStreamConstants.ENTITY_REFERENCE:
                    {
                        final EntityReference entityReference = (EntityReference) event;
                        final EntityDeclaration declaration = entityReference.getDeclaration();
                        text.append(declaration.getReplacementText());
                        break;
                    }
                case XMLStreamConstants.COMMENT:
                case XMLStreamConstants.PROCESSING_INSTRUCTION:
                    {
                        // Ignore
                        break;
                    }
                default:
                    {
                        throw new XMLStreamException(
                                "Unexpected event type '"
                                        + XMLStreamConstantsUtils.getEventName(event.getEventType())
                                        + "' encountered. Found event: "
                                        + event,
                                event.getLocation());
                    }
            }

            event = this.nextEvent();
        }

        return text.toString();
    }
650839
public static String xmlToString(InputStream in) throws AlipayApiException {
        Element root = getRootElementFromStream(in);
        return nodeToString(root);
    }
1182948
XMLReader getXmlReader(final String format) throws SAXException {
        if (format == null || format.equals(ATTR_FORMAT_VALUE_DITA)) {
            return reader;
        }
        for (final Map.Entry<String, String> e : parserMap.entrySet()) {
            if (format.equals(e.getKey())) {
                try {
                    // XMLReaderFactory.createXMLReader cannot be used
                    final XMLReader r = (XMLReader) Class.forName(e.getValue()).newInstance();
                    final Map<String, Boolean> features = parserFeatures.getOrDefault(e.getKey(), emptyMap());
                    for (final Map.Entry<String, Boolean> feature : features.entrySet()) {
                        try {
                            r.setFeature(feature.getKey(), feature.getValue());
                        } catch (final SAXNotRecognizedException ex) {
                            // Not Xerces, ignore exception
                        }
                    }
                    return r;
                } catch (final InstantiationException | ClassNotFoundException | IllegalAccessException ex) {
                    throw new SAXException(ex);
                }
            }
        }
        return reader;
    }
951093
@Override
	public HTTaxinvoice getTaxinvoice(String CorpNum, String NTSConfirmNum,
			String UserID) throws PopbillException {
		
		if ( NTSConfirmNum.length() != 24 )
			throw new PopbillException(-99999999, "국세청승인번호가 올바르지 않았습니다.");
		
		return httpget("/HomeTax/Taxinvoice/" +NTSConfirmNum, CorpNum, UserID, HTTaxinvoice.class);
	}
1042126
public static String toXml(Collection<?> root, String rootName, Class clazz) {
		return toXml(root, rootName, clazz, null);
	}