Parsing XML files easily

To parse a XML (or KML or PMML) file easily without using any complicated softwares, here is a piece of code that fits right in your excel sheet.

Just import this file using Excel, and then use the function getElement, after pasting the XML code in 1 cell.

It is used  for simply reading the xml/kml code as a text string. Just pasted all the xml code in one cell, and used the start ,end function (for example start=<constraints> and end=</constraints> to get the value of constraints in the xml code).

Simply read into the value in another cell using the getElement function.

heres the code if you ever need it.Just paste it into the VB editor of Excel to create the GetElement function (if not there already) or simply import the file in the link above.

Attribute VB_Name = “Module1”
Public Function getElement(xml As String, start As String, finish As String)
For i = 1 To Len(xml)
If Mid(xml, i, Len(start)) = start Then
For j = i + Len(start) To Len(xml)
If Mid(xml, j, Len(finish)) = finish Then
getElement = Mid(xml, i + Len(start), j – i – Len(start))
Exit Function
End If
Next j
End If
Next i
End Function

FOR Using the R Package for parsing XML …………………………reference this site –

http://www.omegahat.org/RSXML/Overview.html

or this thread from R -Help

> Lines <- ‘
+ <root>
+  <data loc=”1″>
+    <val i=”t1″> 22 </val>
+    <val i=”t2″> 45 </val>
+  </data>
+  <data loc=”2″>
+    <val i=”t1″> 44 </val>
+    <val i=”t2″> 11 </val>
+  </data>
+ </root>
+ ‘
>
> library(XML)
> doc <- xmlTreeParse(Lines, asText = TRUE, trim = TRUE, useInternalNodes = TRUE)
> root <- xmlRoot(doc)
>
> data1 <- getNodeSet(root, “//data”)[[1]]
> xmlValue(getNodeSet(data1, “//val”)[[1]])
[1] ” 22 “

SAS Analytics :Google Earth and Lex Jansen’s Site

Google earth stores values into KML files . These are almost like XMl file formats. The zipped versions of the KML file is the KMZ file .(It beats me why Google Wanted to create a zipped file format for KML ,since most KML files are extremely small).

To do any geo-coding analysis with Google Earth, here are two SAS papers from Lex Jansen’s terrific site.

1) 

Put Your Customers on the Map: Integrating SAS/GRAPH and Google Earth
(http://www2.sas.com/proceedings/forum2008/252-2008.pdf)

Daniel Kuiper, Koen Vyverman (SAS Global Forum, 2008-03)

 

and

2) Using SAS and Google Earth to Access and Display Air Pollution Data

(http://www2.sas.com/proceedings/forum2008/253-2008.pdf)
Joshua Drukenbrod, David Mintz (SAS Global Forum, 2008-03)

 

These two papers are great in the way they use Google Earth for geo coding analysis and visual representation. They however require SAS to be licensed with you.

Lex Jansen ‘s site is generally considered the de facto site to search for analytics especially related to SAS.

 

 

 

 

 

 

 

 

 

 

 

 

Upcoming Book

The great Bob Muenchen, is coming with the very good updated version of the R for SAS and SPSS users book— in September 2008 to help people learn R , if they have used only SAS or SPSS before.We first covered the earlier edition of the book here.The book adds sections on R Commander, Rattle and JGR as well as two chapters on graphics ; one on basic stats. The author runs the examples and walks though them explaining each step, especially where the results differ from SAS & SPSS. Check the new book here-

http://www.amazon.com/SAS-SPSS-Users-Statistics-Computing/dp/0387094172/ref=pd_bbs_sr_1?ie=UTF8&s=books&qid=1217456813&sr=8-1

The Great Connector ,Stan Relihan

Note from Ajay-

Stan Relihan is the 40th most connected person list on LinkedIn out of 25 million people.His podcast: http://connections.thepodcastnetwork.com gets more than 12,000 downloads a month and he has leveraged social networking to maximum advantage for building great assets as well as increasing his own business value. Here he shares some insights  on using social networking networks.

1) What’s the latest trend you see in community sites over the next year and next three to five years.

I see more and more emphasis on the need to focus on Business outcomes -not just idle chit-chat or frivolous questions. Social Networking sites will also need to truly embrace the Web 2.0 ethos – where what the users want is ultimately more important that what the site owner / operators think it should be.  This means more responsiveness to requests for new features and more transparency & intercommunication from management with their users. In the end, just like with Search Engines & Operating Systems, many will cease to exist – and only a few dominant players will continue.

Continue reading “The Great Connector ,Stan Relihan”