Nesting xml/CDATA into a xml file?

Yes, in your top-most document make the CDATA section of data type bin. Base64. That way even if the document you're wrapping contains a CDATA section, you're protected.

As an added bonus, your application will also support binary files (images, spreadsheets, etc.).

Up vote 0 down vote favorite share g+ share fb share tw.

I need to put a rather large xml file into another xml file. I considered using CDATA for this: w3.org/TR/2000/REC-xml-20001006#sec-cdat... w3schools.com/xml/xml_cdata.asp but since my xml might also contain CDATA this does not work unless I do some nasty workaround: web-design.blogs.webucator.com/2010/11/2... Are there better ways of transferring/encoding large nested xml files or is the xml format simply not meant to be used in this way? Xml cdata link|improve this question asked Nov 14 '11 at 15:28tul411415 58% accept rate.

Yes, in your top-most document make the CDATA section of data type bin. Base64. That way even if the document you're wrapping contains a CDATA section, you're protected.

As an added bonus, your application will also support binary files (images, spreadsheets, etc.). Here's some code that does it, based on Microsoft ADO, and MSXML. Function wrapBinaryFile( strFileName) { var ado_stream = new ActiveXObject("ADODB.

Stream"); var xml = newXMLDocument(); xml. LoadXML(""); xml.documentElement. SetAttribute( "name", strFileName ); xml.documentElement.

SetAttribute("xmlns:dt","urn:schemas-microsoft-com:datatypes"); xml.documentElement. DataType = "bin. Base64"; ado_stream.

Type = 1; // 1=adTypeBinary ado_stream.Open(); ado_stream. LoadFromFile( strFileName ); xml.documentElement. NodeTypedValue = ado_stream.

Read(-1); // -1=adReadAll ado_stream.Close(); return xml; } And how to un-wrap it on the other end... function unwrapBinaryFile(ndFile, strFileName ) { var ado_stream = new ActiveXObject("ADODB. Stream"); ndFile. DataType = "bin.

Base64"; ado_stream. Type = 1; // 1=adTypeBinary ado_stream.Open(); ado_stream. Write( ndFile.

NodeTypedValue ); ado_stream. SaveToFile( strFileName, 2 ); ado_stream.Close(); }.

I don't speak english very well, but i'm trying! First XML : test2 Second XML : test4 In my opinion, you should include second XML in the first with specific node : test2 test4 You can do this with a simple inclusion.

Apart from DTD issues, any XML document can be copied as the content of an element in another document.

The short answer is that XML is not meant to be used in this way! However, if you base64-encode the XML file to be packaged, the encoded result will not contain any characters which might be interpreted either as markup, or as entity references, and can safely be held as the contents of a text node.

1 If XML documents are not to be embedded in other XML documents, I'd guess XSLT and SOAP have something of a problem. – G_H Nov 14 '11 at 16:43 XML elements can certainly be embedded in other XML documents: However an XML document SHOULD include an XML declaration, which can only appear at the satrt of the document, hence cannot be embedded without encoding in some way. – Max Nov 14 '11 at 16:56 It's usually little work to get around that.

Whether using SAX or DOM, or some other technology, using only the root node as an element or turning an element into a new document is trivially easy. Copying over the XML declaration could even prove harmful if the specified encoding is no longer appropriate. – G_H Nov 14 '11 at 16:59.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions