Parse XML: Difference between revisions
Jump to navigation
Jump to search
Jkuehlthau (talk | contribs) (Created page with "First I add code and External Assemblies to the .NET GLobal section of the Mapping tab: <source lang="csharp"> using System; using System.Collections.Generic; using System.Xml...") |
Jkuehlthau (talk | contribs) No edit summary |
||
Line 8: | Line 8: | ||
</source> | </source> | ||
External Assemblies: System.dll,,System.Xml.dll,System.Data.dll | External Assemblies: System.dll,,System.Xml.dll,System.Data.dll | ||
Second I populate the global variables using a Repeat Each Row Before Operation: | |||
<source lang="csharp"> | |||
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"); | |||
} | |||
</source> | |||
Third, I populate a field with data from the global variable: | |||
<source lang="csharp"> | |||
object ScriptedField() | |||
{ | |||
string res = ""; | |||
foreach (XmlNode node in nodes) | |||
{ | |||
res = node["EXTITLE"].InnerText; | |||
} | |||
return res; | |||
} | |||
</source> |
Latest revision as of 18:39, 5 April 2019
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; }