Category: XHTML

Working with XML documents is the new way of EDI in today’s business work.  XML to XML provides a way to not only translate data that you want to work with, but also provides a way to store extreme amounts of information in a structured manner.  In this article I will discuss how to use XML in two forms, XML to XML or moving one XML document to another XML document and translating it along the way and XML to Object.  XML to Objects will be used in the XML to XML process but it will also help with keeping your XML uniform as well.

The most important piece in XML to XML is uniform documents

Starting out with a fresh document is very important in being successful in translation.  Here is an example of a simple yet effective XML document:

xml to xml job definition

The first part of XML to XML is to load the document into a XmlDocument file.  We do this through instantiating a XmlDocument and calling the Load method targeting our file.  The XmlDocument will be used to populate our new document and then write out to finish our XML to XML process.

            XmlDocument xmlJobDoc = new System.Xml.XmlDocument();
            XmlDocument xmlLoadDocument = new System.Xml.XmlDocument();
            XmlNode xmlJobNode;
            XmlAttribute xmlAttribute;
            XmlNode xmlRootNode = xmlLoadDocument.CreateElement("Root");
            xmlJobDoc.Load("JobDefinition.xml");
            for (int i = 0; i < 2; i++)
            {
                xmlJobNode = xmlLoadDocument.CreateElement("TruckRun");
                xmlAttribute = xmlLoadDocument.CreateAttribute("JobNumber");
                xmlAttribute.Value = i.ToString();
                xmlJobNode.Attributes.Append(xmlAttribute);

                xmlJobNode.AppendChild(xmlLoadDocument.ImportNode(xmlJobDoc.DocumentElement,true));
                xmlRootNode.AppendChild(xmlJobNode);
            }
            xmlLoadDocument.AppendChild(xmlRootNode);
            xmlLoadDocument.Save("JobFile.xml");

Xml to Xml utilizing Xml ImportNode Command

This will utilize the Xml to Xml specific command called ImportNode. ImportNode is powerful as it allows you to copy one specific section of an Xml document to another Xml document or use the Xml to Xml functionality as if you were copy and pasting. To finish up the Xml to Xml translation, we utilize the Save method on the Xml document and push the information to the specified file.  If you would like to learn more about translating Xml documents from Xml to Xml or other Xml processing capabilities of Microsoft dotNet Framework, check out this MSDN article.

XHTML has been severely damaged as the future leader of the web standards In the first half of the decade, XHTML had been marketed as the say all do all for how to progress your websites. It had introduced a new standard for being compliant with XML documentation and was hoped to be the future of the web in general. Present day, we all know that XML is not exactly the future of web design and proper data storage. While XML does have it’s place, and so does XHTML, they both can be phased out easily with a few simple arguments.

The biggest disadvantage to using XHTML being, any user agent (e.g. the browser) when it comes across an unescape ampersand (&) in a URL or a mismatched character encoding in a track back message, would cause the entire page to fail, and so most of today’s public web applications can’t safely be incorporated in a true XHTML page.Internet Explorer has never supported XHTML (not even IE 8) making all arguments about standards compliance go down the drain.

XHTML is not HTML compliant if it is served as content type text/html (read more on why sending XHTML as text/html is harmful). Moreover, XHTML 2 is not compatible with XHTML 1.1, which throws the future compatibility argument out of the window. Others have doubts over XHTML and XHTML 2.0 which paved the way for HTML 5.

I am personally looking forward to moving clients to HTML version 5 based on some of the tags I have seen come out. While this doesn’t seem to impress most, being able to embed document content directly in a page is going to be fantastic. Also, there looks like there is a curve with HTML interpreters to shift towards visual design and actions instead of rendering text. This is an exciting time for web pages and the web in general, glad it’s finally here.

Sponsored Links