Question

Est-ce que quelqu'un sait s'il y a un moyen simple de sérialiser un analysable cyberneko ElementNSImpl objet?

Voici mon exemple dans Clojure de sérialisation l'ensemble DOM (un objet HTMLDocumentImpl). Cela fonctionne, mais je n'ai pas encore compris comment faire pour un élément du dom (ElementNSImpl).

(defn dom->xml
  [dom]
  (let [sw (java.io.StringWriter.)] 
    (.serialize 
     (org.apache.xml.serialize.XMLSerializer. 
      sw (org.apache.xml.serialize.OutputFormat. dom)) 
     dom)
    (.toString sw)))

Merci, Rob

Était-ce utile?

La solution

Cela fonctionne pour la sortie XML, mais je ne sais toujours pas comment la sortie HTML:

(defn dom->xml
  "serialize a dom element back to XML text"
  [elem]
  (let [sw (java.io.StringWriter.)]
    (.serialize
     (org.apache.xml.serialize.XMLSerializer. 
      sw (org.apache.xml.serialize.OutputFormat.))
     elem)
    (str sw)))
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top