Parse XML

Parse XML

First I add code and External Assemblies to the .NET GLobal section of the Mapping tab:

using System;
using System.Collections.Generic;
using System.Xml;
XmlDocument demographicsXML = new XmlDocument();
XmlNodeList nodes;

External Assemblies: System.dll,,System.Xml.dll,System.Data.dll

Second I populate the global variables using a Repeat Each Row Before Operation:

using System;
using System.Collections.Generic;
using System.Xml;
void CSharpProcedure()
{
	string demographicsString = "<Demographics>"+Starfish.OriginData["DEMOGRAPHICS"].ToString()+"</Demographics>";
	demographicsXML.LoadXml(demographicsString);
	nodes = demographicsXML.DocumentElement.SelectNodes("/Demographics");
}

Third, I populate a field with data from the global variable:

object ScriptedField()
{
	string res = "";
	foreach (XmlNode node in nodes)
	{
		res = node["EXTITLE"].InnerText;
	}
	return res;
}
    • Related Articles

    • XML (Xpath) Connector

      There is currently no text on this page. Parameter Description File Root Element Name Namespace XML Connection Edit Screen
    • Editing XML

      Your entire mapping file is stored as encrypted XML in the .spd file. You can review and edit this XML directly by clicking on the Edit XML button on the General tab. In here you can edit, remove, copy jobs, stages, etc. If you decide to copy a job, ...
    • Validate and parse JSON

      This is a link to a page that will validate/parse your JSON: http://jsonlint.com/
    • Parse text and look up ID based on result

      This script parses out the first Lead Source from a comma or semi-colon separated list and then gets the Lead Source ID from an xRef list. Function ScriptedField Dim ls Dim res ls = "@@ORG:CUSTOM07@@" If Len(ls) <> 2 Then If InStr(ls,",") > 0 Then ls ...
    • File System Connector

      File System Origin The File System Connector reads all files from a folder specified in the Directory field. The Username and Password fields are not used. Filter can be used to filter for certain file names/extensions. To search for all files with ...