<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Johan Känngård &#187; XML</title>
	<atom:link href="http://johankanngard.net/category/programming/xml/feed/" rel="self" type="application/rss+xml" />
	<link>http://johankanngard.net</link>
	<description>Useful tips for developers</description>
	<lastBuildDate>Thu, 19 May 2011 18:40:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Managing logging with Log4j and Chainsaw</title>
		<link>http://johankanngard.net/2007/06/19/managing-logging-with-log4j-and-chainsaw/</link>
		<comments>http://johankanngard.net/2007/06/19/managing-logging-with-log4j-and-chainsaw/#comments</comments>
		<pubDate>Tue, 19 Jun 2007 11:52:32 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[Log4j]]></category>
		<category><![CDATA[logging]]></category>

		<guid isPermaLink="false">http://johankanngard.net/2007/06/19/managing-logging-with-log4j-and-chainsaw/</guid>
		<description><![CDATA[Those of you who haven&#8217;t used System.out.println(&#8220;My variable: &#8221; + myVariable) in some Java classes to get debug information to the console, raise your hands please. None? ;-) I am very fond of logging as a complement to debugging, since I can &#8220;trace&#8221; actions in my programs even if the classes is in production. &#8220;But [...]]]></description>
			<content:encoded><![CDATA[<p>Those of you who haven&#8217;t used System.out.println(&#8220;My variable: &#8221; + myVariable) in some Java classes to get debug information to the console, raise your hands please. None? ;-)</p>
<p>I am very fond of logging as a complement to debugging, since I can &#8220;trace&#8221; actions in my programs even if the classes is in production. &#8220;But hey, logging makes the application go slower!&#8221; you might think. Well, it&#8217;s up to you to decide, a small performance hit is likely to occur, a big hit if you don&#8217;t read the documentation of for instance the <a href="http://logging.apache.org/log4j/docs/api/org/apache/log4j/PatternLayout.html">PatternLayout</a>.<br />
I use <a href="http://logging.apache.org/log4j">Log4j</a> a lot in the Java code I design and write, and haven&#8217;t noticed any big difference between logging and not logging.<br />
So, you might have used Log4j a bit and used <a href="http://logging.apache.org/log4j/docs/chainsaw.html">Chainsaw</a> to look at Log4j logging files. Why not look at the logging in realtime? Here is how to do it.<br />
<span id="more-126"></span><br />
<script type="text/javascript"><!--
google_ad_client = "pub-8220767383302774";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "CCCCCC";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_url = "666666";
google_color_text = "333333";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h2>Setting up Log4j</h2>
<p>To see the logging in real time, I use an appender called SocketHubAppender that acts as a server. Create the log4j.xml in the root of your Java application&#8217;s directory, or add the vital bits to your own:<br />
<code><br />
< ?xml version=\"1.0\" encoding=\"UTF-8\" ?><br />
< !DOCTYPE log4j:configuration SYSTEM \"log4j.dtd\"><br />
<log4j :configuration xmlns:log4j=\'http://jakarta.apache.org/log4j/\'<br />
	debug=\"true\"><br />
	<appender name=\"SOCKET\"<br />
		class=\"org.apache.log4j.net.SocketHubAppender\"></p>
<param name=\"port\" value=\"1020\" />
	</appender><br />
	<root></p>
<priority value=\"debug\" />
		<appender -ref ref=\"SOCKET\" /><br />
	</root><br />
</log4j></p>
<p><root></p>
<priority value=\"debug\" />
	<appender -ref ref=\"SOCKET\" /><br />
</root></p>
<p></code></p>
<p>When starting your application and outputs some logging messages with the usual logger.debug(&#8220;Hello world!&#8221;); it will be sent to the appender&#8217;s socket, defined above as 1020. The output can&#8217;t be read using a telnet session, because the things you will see is the logging events serialized&#8230; You need something to look at those serialized logging events with &#8211; Chainsaw!</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8220767383302774";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "CCCCCC";
google_color_bg = "FFFFFF";
google_color_link = "000000";
google_color_url = "666666";
google_color_text = "333333";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h2>Configure Chainsaw</h2>
<p>Create a file (or add the vital bits below to your own&#8230;) called chainsaw-config.xml somewhere on your local disk, for instance c:\temp\chainsaw-config.xml, and change the host from my.remote.host.net to the host where you set up the logging with the SocketHubAppender and that the port matches the one you used:<br />
<code><br />
< ?xml version=\"1.0\" encoding=\"UTF-8\" ?><br />
< !DOCTYPE log4j:configuration ><br />
<!-- Chainsaw receiver configuration--><br />
<log4j :configuration xmlns:log4j=\"http://jakarta.apache.org/log4j/\" debug=\"true\"></p>
<plugin name=\"MyRemoteLogging\" class=\"org.apache.log4j.net.SocketHubReceiver\">
<param name=\"Port\" value=\"1020\"/>
<param name=\"Host\" value=\"my.remote.host.net\"/>
   </plugin>
<p>   <root><br />
      <level value=\"debug\"/><br />
   </root><br />
</log4j><br />
</code><br />
<a href="http://logging.apache.org/log4j/docs/webstart/chainsaw/chainsawWebStart.jnlp">Start Chainsaw</a> via <a href="http://java.sun.com/products/javawebstart/">Java Web Start</a> by launching the jnlp-file at the <a href="http://logging.apache.org/log4j/docs/chainsaw.html">homepage</a>. Open the menu &#8220;View&#8221;, &#8220;Show Application-wide Preferences&#8221;, go to the &#8220;General&#8221; tab and enter &#8220;file://c:/temp/chainsaw-config.xml&#8221; (leave out the quotation marks) in the &#8220;Automatic Configuration URL&#8221; field, or whatever you named your config file. Click &#8220;OK&#8221; and restart Chainsaw. You should now see your receiver to the right named &#8220;MyRemoteLogging&#8221;.<br />
Try starting up your Java application and output some logging, and you will see them pop up directly in Chainsaw!</p>
<p>So why not use a simple file or database to log to? You can do that too, you are not limited to one appender per application. You can set up as many as you want, for instance a ConsoleAppender, a SocketHubAppender and a JDBCAppender that logs the events to all those targets.<br />
Log4j is powerful, but it doesn&#8217;t makes miracles if you don&#8217;t use some structured logging. Events like &#8220;Hello world!&#8221; is not going to help you, but some well designed NDC.push()&#8217;s and other will do good. And don&#8217;t forget to add the <a href="http://dev.kanngard.net/Permalinks/ID_20030210235410.html">NotesExceptionRenderer</a> to your class path, so that you get more info from those badly-designed exceptions :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2007/06/19/managing-logging-with-log4j-and-chainsaw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>g33k date</title>
		<link>http://johankanngard.net/2007/05/25/g33k-date/</link>
		<comments>http://johankanngard.net/2007/05/25/g33k-date/#comments</comments>
		<pubDate>Fri, 25 May 2007 09:59:54 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[Domino/Notes]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://johankanngard.net/2007/05/25/g33k-date/</guid>
		<description><![CDATA[I was a key speaker at the first g33k date ever yesterday, and it was Ekakan that held the meeting in their small but great office at SaltmÃ¤targatan in Stockholm. Quite a lot showed up, many of which I know by name, but not by face, since they are all bloggers with no pictures at [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/kanngard/125357142/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/1/125357142_9c702152d7.jpg" width="500" height="281" alt="Johan defeating Darth Vader" style="float:none;" /></a><br />
I was a key speaker at the first g33k date ever yesterday, and it was <a href="http://ekakan.com/g33k">Ekakan</a> that held the meeting in their small but great office at SaltmÃ¤targatan in Stockholm. Quite a lot showed up, many of which I know by name, but not by face, since they are all bloggers with no pictures at their sites! :-) After having slurped down some well-known red-canned sugary liquid, I started my speech using <a href="http://www.openoffice.org">OpenOffice</a> Impress as presenter application. The slides can be found at the bottom of this post. It has not been cleaned up, so some references are to my local file system and applications on my Domino server will not work. I have put the database I used for the web service stuff as an attachment below, but use it at your own risk!<br />
I talked briefly about who I am, what I like, what my shoe size is and other important stuff. A short history on how the web has evolved over time (1.0, 1.5, 2.0) and my own suggestion of the next 3.0 level, which includes web services on the client side. I demonstrated a simple AJAX solution for typeahead with script.aculo.us and Domino and a web service consumer in the browser.<br />
A Midlet with a web service consumer was the next item to show, and it worked as a charm in the emulator!<br />
After my 15 minutes of fame (or rather 40), we had a short drinking and chatting pause.</p>
<p><a href="http://domino.dagerot.com/">Joachim Dagerot</a> introduced us into <a href="http://extjs.com">ext.js</a>, a client-side framework with lot&#8217;s of goodies like menus, trees, tabbed tables, layouts etc. The framework looked really impressive, and applications based on it was more of a Windows experience. When developing applications with ext.js, almost everything is done in JavaScript, including the templates of the pages. You don&#8217;t have to download the complete framework, you can <a href="http://extjs.com/products/extjs/build/">take bits and pieces</a>, if you want only a part of the gadgets.</p>
<p>After more beverages, snacks and more chatting, connections were made, business cards and email addresses exchanged hands. I left rather early though, I hope my fellow bloggers to give the full story ;-) Photos were taking during the meeting, and I would really love to see them, since I didn&#8217;t use my own camera.</p>
<p>I hope that this event wasn&#8217;t the last of it&#8217;s kind in Sweden, it was great fun to see fellow bloggers and geeks!<br />
Thanks for a great event everyone, especially <a href="http://ekakan.com">Ekakan</a> who arranged the g33k date!!</p>
<p>Btw, the picture at the top is NOT from the g33k date, it was just a picture I used in the presentation as an illustration of the thin red line between being a geek and a nerd. :-D</p>
<ul>
<li><a href="/wp-content/uploads/2007/05/g33kdate001.pdf" title="g33k date presentation">g33k date presentation</a></li>
<li><a href="/wp-content/uploads/2007/05/g33kdate.zip" title="g33kdate.nsf zipped">g33kdate.nsf zipped</a></li>
<li><a href="http://eclipseme.org/">EclipseMe</a>, J2ME plug in for <a href="http://eclipse.org">Eclipse</a></li>
<li><a href="http://java.sun.com/products/sjwtoolkit/">Sun Java Wireless Toolkit</a></li>
<li><a href="http://www.geology.smu.edu/~dpa-www/robo/nbot/">nbot</a></li>
</ul>
<p>[tags]g33k, geek, J2ME, AJAX, Webservice, Ekakan[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2007/05/25/g33k-date/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Echo XML from a file, String or InputStream in Java with SAX</title>
		<link>http://johankanngard.net/2006/02/13/echo-xml-from-a-file-string-or-inputstream-in-java-with-sax/</link>
		<comments>http://johankanngard.net/2006/02/13/echo-xml-from-a-file-string-or-inputstream-in-java-with-sax/#comments</comments>
		<pubDate>Mon, 13 Feb 2006 13:51:06 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[Domino/Notes]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://johankanngard.net/2006/02/13/echo-xml-from-a-file-string-or-inputstream-in-java-with-sax/</guid>
		<description><![CDATA[Here is an example how to use the XMLEchoer class, that I have refurbished from Sun&#8217;s tutorial Echoing an XML File with the SAX Parser. It is of limited use, but can be a good start learning SAX. import java.io.PrintWriter; import lotus.domino.AgentBase; import net.kanngard.xml.XMLEchoer; public class JavaAgent extends AgentBase { public void NotesMain() { try [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an example how to use the XMLEchoer class, that I have refurbished from <a href="http://www.sun.com">Sun&#8217;s</a> tutorial <a href="http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/2a_echo.html">Echoing an XML File with the SAX Parser</a>. It is of limited use, but can be a good start learning SAX.<br />
<code><br />
import java.io.PrintWriter;<br />
import lotus.domino.AgentBase;<br />
import net.kanngard.xml.XMLEchoer;</p>
<p>public class JavaAgent extends AgentBase {</p>
<p>    public void NotesMain() {</p>
<p>        try {<br />
            String xml = "<test>Hello World</test>";<br />
            PrintWriter writer = getAgentOutput();<br />
            writer.println("Content-type: text/xml");<br />
            XMLEchoer echoer = new XMLEchoer(writer);<br />
            echoer.start(xml);<br />
        } catch(Exception e) {<br />
            e.printStackTrace();<br />
        }<br />
    }<br />
}<br />
</code></p>
<p>To get it working, you need a SAX implementation, like <a href="http://xerces.apache.org/xerces2-j/">Apache Xerces 2</a>. Just drop the JAR files from Xerces 2 into the jvm/lib/ext directory in your Notes or Domino installation. Restart the http task if you are testing with Domino.</p>
<ul>
<li><a id="p95" href="http://johankanngard.net/wp-content/uploads/2006/02/XMLEchoer.java">XMLEchoer.java</a></li>
</ul>
<p>[tags]Java, XML, SAX[/tags]</p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2006/02/13/echo-xml-from-a-file-string-or-inputstream-in-java-with-sax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML Parser Performance in LotusScript</title>
		<link>http://johankanngard.net/2006/01/17/xml-parser-performance-in-lotusscript/</link>
		<comments>http://johankanngard.net/2006/01/17/xml-parser-performance-in-lotusscript/#comments</comments>
		<pubDate>Tue, 17 Jan 2006 13:58:56 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[LotusScript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://johankanngard.net/?p=55</guid>
		<description><![CDATA[I am not Microsoft&#8217;s biggest fan, since I was a Macintosh fanatic in the old days, but had to convert into the Wintel platform for about 10 years ago. :-) But I have to admit though, when comparing Microsoft&#8217;s XML parser with the ones that are built into Notes/Domino, that their products sometimes are great! [...]]]></description>
			<content:encoded><![CDATA[<p>I am not Microsoft&#8217;s biggest fan, since I was a Macintosh fanatic in the old days, but had to convert into the Wintel platform for about 10 years ago. :-) But I have to admit though, when comparing <a href="http://www.microsoft.com/downloads/details.aspx?familyid=993C0BCF-3BCF-4009-BE21-27E85E1857B1&#038;displaylang=en">Microsoft&#8217;s XML parser</a> with the ones that are built into Notes/Domino, that their products sometimes are great!<br />
When comparing Microsoft&#8217;s XML parser with the other two, I created an agent that parsed a big (over 700 KB) and complex XML document and read an element&#8217;s value. I did this 25 times per parser, and came up with this interesting result (average execution time per parser) when executed in the Notes client:</p>
<ol>
<li>Microsoft XML Parser: 0.2 seconds</li>
<li>NotesSAXParser: 2.2 seconds </li>
<li>NotesDOMParser: 2.5 seconds</li>
</ol>
<p>When executed on a Domino server, the result was a bit different, since the server is a bit old:</p>
<ol>
<li>Microsoft XML Parser: 1.0 seconds</li>
<li>NotesSAXParser: 5.0 seconds </li>
<li>NotesDOMParser: 7.7 seconds</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2006/01/17/xml-parser-performance-in-lotusscript/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Manually serializing NotesDOMNodes</title>
		<link>http://johankanngard.net/2006/01/11/manually-serialize-notesdomnodes/</link>
		<comments>http://johankanngard.net/2006/01/11/manually-serialize-notesdomnodes/#comments</comments>
		<pubDate>Wed, 11 Jan 2006 17:41:30 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[LotusScript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://johankanngard.net/?p=52</guid>
		<description><![CDATA[In my earlier post today, I described a problem I have, where I wanted to get the XML string of a DOM tree. I&#8217;ve started writing my own routine, this is what I have right now. It&#8217;s far from complete, since it can not handle namespaces, CDATA etc. yet: This is a new version that [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="/2006/01/11/serialize-a-dom-tree-in-lotusscript/">earlier post</a> today, I described a problem I have, where I wanted to get the XML string of a DOM tree. I&#8217;ve started writing my own routine, this is what I have right now. It&#8217;s far from complete, since it can not handle namespaces, CDATA etc. yet:<br />
<ins datetime="2006-01-13T12:59:47+00:00">This is a new version that handles siblings better, and not getting out of stack space :-)</ins></p>
<p><code><br />
Public Sub serializeNode(node As NotesDOMNode_<br />
, outStream As NotesStream)<br />
	On Error Goto catch</p>
<p>	If node.IsNull Then Exit Sub</p>
<p>	Dim currentNode As NotesDOMNode<br />
	Set currentNode = node</p>
<p>	Do Until currentNode.isNull<br />
		Select Case currentNode.nodeType<br />
		Case DOMNODETYPE_DOCUMENT_NODE<br />
		Case DOMNODETYPE_XMLDECL_NODE<br />
			Dim xmlDecl As NotesDOMXMLDeclNode<br />
			Set xmlDecl = currentNode<br />
			Call outStream.WriteText("< ?xml version=""" _<br />
+ xmlDecl.version + """ encoding=""" + xmldecl.encoding + """?>")<br />
		Case DOMNODETYPE_ELEMENT_NODE<br />
			Call outStream.writeText("< " + currentNode.nodeName + "")<br />
			Dim nodeMap As NotesDOMNamedNodeMap<br />
			Set nodeMap = currentNode.attributes<br />
			Dim attribute As NotesDOMNode<br />
			Dim i As Integer</p>
<p>			For i = 1 To nodeMap.numberOfEntries<br />
				Set attribute = nodeMap.getItem(i)<br />
				Call outStream.WriteText(" " + attribute.nodeName + "=")<br />
				Call outStream.WriteText("""" + attribute.NodeValue + """")<br />
			Next i<br />
			Call outStream.writeText(">")<br />
		Case DOMNODETYPE_TEXT_NODE<br />
			Call outStream.writeText(currentNode.NodeValue)<br />
		Case DOMNODETYPE_COMMENT_NODE<br />
			Call outStream.writeText("<!--" _<br />
+ currentNode.NodeValue + "-->")<br />
		Case Else<br />
			Error 2000, "Unhandled node type [" _<br />
&#038; currentNode.nodeType &#038; "]"<br />
		End Select</p>
<p>		Dim endWritten As Boolean</p>
<p>		If currentNode.hasChildNodes Then<br />
			Call serializenode(currentNode.firstChild, outStream)<br />
		End If</p>
<p>		If currentNode.NodeType = DOMNODETYPE_ELEMENT_NODE Then<br />
			Call outStream.writeText("")<br />
			endWritten = True<br />
		End If</p>
<p>		Set currentNode = currentNode.nextSibling<br />
	Loop</p>
<p>	If node.NodeType = DOMNODETYPE_ELEMENT_NODE _<br />
And Not endWritten Then<br />
		Call outStream.writeText("")<br />
	End If<br />
	Exit Sub<br />
catch:<br />
	Error Err, Err &#038; Lsi_Info(2) &#038; ":" &#038; Erl &#038; "|" &#038; Error<br />
End Sub<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2006/01/11/manually-serialize-notesdomnodes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Serialize a DOM tree in LotusScript?</title>
		<link>http://johankanngard.net/2006/01/11/serialize-a-dom-tree-in-lotusscript/</link>
		<comments>http://johankanngard.net/2006/01/11/serialize-a-dom-tree-in-lotusscript/#comments</comments>
		<pubDate>Wed, 11 Jan 2006 16:28:52 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[LotusScript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://johankanngard.net/?p=51</guid>
		<description><![CDATA[I have a problem, that nor I nor any of my colleagues can&#8217;t solve easily. I have several classes that are passing objects/variables between them. On of them is handling Web Service request, and parsing the responses to a NotesDOMDocumentNode via the NotesDOMParser. The NotesDOMDocumentNode is passed returned, and are used in several places to [...]]]></description>
			<content:encoded><![CDATA[<p>I have a problem, that nor I nor any of my colleagues can&#8217;t solve easily. I have several classes that are passing objects/variables between them. On of them is handling <a href="http://www.w3.org/2002/ws/">Web Service</a> request, and parsing the responses to a NotesDOMDocumentNode via the NotesDOMParser. The NotesDOMDocumentNode is passed returned, and are used in several places to extract information. But, I need to cache the response, so concurrent request with the same parameters are sped up.<br />
To cache the response, I need to serialize the NotesDOMDocumentNode. At first, I thought this was easy, since there is a Serialize method on the NotesDOMParser. But no&#8230; You have to keep the original NotesDOMParser that parsed the raw XML data. The only solutions I can figure out are:</p>
<ul>
<li>pass both the NotesDOMDocumentNode AND the original NotesDOMParser at all times</li>
<li>write my own Serialize method</li>
<li>pass the XML string only, and do the parsing at each method. I think this would be really slow&#8230;</li>
</ul>
<p>To further illustrate what I want, here is an example:<br />
<code><br />
Public Sub testDOMParser()<br />
	Dim parser As NotesDOMParser<br />
	Dim inStream As NotesStream<br />
	Dim node As NotesDOMDocumentNode<br />
	Set inStream = session.createStream()<br />
	Call inStream.open("c:\temp\test.xml")<br />
	Set parser = session.createDOMParser(inStream)<br />
	Call parser.process()<br />
	Set node = parser.document<br />
	Call serializeDocument(node)<br />
End Sub<br />
Public Sub serializeDocument(node As NotesDOMDocumentNode)<br />
	' Here, I want to do something like this:<br />
	Dim outStream As NotesStream<br />
	Dim parser As NotesDOMParser<br />
	Set outStream = session.createStream()<br />
	Set parser = session.createDOMParser(node, outStream)<br />
	parser.exitOnFirstFatalError = True<br />
	Call parser.serialize()<br />
	Print "Serialized tree: " + outStream.readText()<br />
End Sub<br />
</code></p>
<p>Anyone who have had any experience with this and are willing to share their thoughts? We are talking R6 here&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2006/01/11/serialize-a-dom-tree-in-lotusscript/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Getting the root element node in XML using LotusScript</title>
		<link>http://johankanngard.net/2005/12/16/getting-the-root-element-node-in-xml-using-lotusscript/</link>
		<comments>http://johankanngard.net/2005/12/16/getting-the-root-element-node-in-xml-using-lotusscript/#comments</comments>
		<pubDate>Fri, 16 Dec 2005 10:32:56 +0000</pubDate>
		<dc:creator>Johan Känngård</dc:creator>
				<category><![CDATA[LotusScript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://johankanngard.net/?p=39</guid>
		<description><![CDATA[So I don&#8217;t forget the next time I want to do this, and trust me, I got a short memory! Dim xml As String Dim rootElementNode As NotesDOMElementNode xml = "YOUR XML HERE" Set rootElementNode = parseXML(xml)._ getElementsByTagName("THE ROOTNODE").getItem(1) Public Function parseXML(xml As String) _ As NotesDOMDocumentNode ' Parses the specified xml. On Error Goto [...]]]></description>
			<content:encoded><![CDATA[<p>So I don&#8217;t forget the next time I want to do this, and trust me, I got a short memory!<br />
<code><br />
Dim xml As String<br />
Dim rootElementNode As NotesDOMElementNode<br />
xml = "YOUR XML HERE"<br />
Set rootElementNode = parseXML(xml)._<br />
getElementsByTagName("THE ROOTNODE").getItem(1)<br />
Public Function parseXML(xml As String) _<br />
As NotesDOMDocumentNode<br />
	' Parses the specified xml.<br />
	On Error Goto catch<br />
	Dim session As New NotesSession()<br />
	Dim stream As NotesStream<br />
	Set stream = session.createStream()<br />
	Call stream.writeText(xml)<br />
	Dim domparser As NotesDOMParser<br />
	Set domparser = session.createDOMParser(stream)<br />
	domParser.exitOnFirstFatalError = True<br />
	Call domParser.parse()<br />
	Set parseXML = domparser.Document<br />
	Exit Function<br />
catch:<br />
	Error Err, _<br />
Err &#038; "|" &#038; Error &#038; "|" &#038; Lsi_info(2) &#038; ":" &#038; Erl<br />
End Function<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://johankanngard.net/2005/12/16/getting-the-root-element-node-in-xml-using-lotusscript/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

