Skip to content
Prev 155267 / 398521 Next

XML - get node by name

well not sure how its done in R , but heres a way to do it in simple Excel.
http://decisionstats.com/2008/parsing-xml-files-easily/

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.

xml-getelement

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
On Sun, Sep 7, 2008 at 1:52 PM, Antje <niederlein-rstat at yahoo.de> wrote:
--
Regards,

Ajay Ohri
http://tinyurl.com/liajayohri