Rashmi kaneri

Rashmi kaneri

  • NA
  • 6
  • 5.4k

how to write C# code from vbScript

Aug 16 2016 12:30 AM
I am new to C#  and i am given vbscript to convert to "create xml file" in C#.
i don't understand Dim and how to interpret in C#. Can someone please provide Sample code for this.
 Please help
 
Function FWC_UTL_XML_CreateXML(strPath)
'On Error Resume Next
Dim objDOM, objNode, objManager, objTester, objDeveloper, ObjHighLevel, objGrandChildNode
Dim strHighLevelInfoPath, strText, strNodes, strNodesScplit, strSplit, IntCount
' Create the main xml node
Set objDOM = CreateObject("Microsoft.XMLDOM")
' Set objNode = objDOM.createNode(7, "xml", "")
' objDOM.appendChild objNode
Set objNode = objDOM.CreateProcessingInstruction("xml-stylesheet", "type='text/xsl' href='XmlReference/LogReport.xsl'")
objDOM.InsertBefore objNode, objDOM.childNodes(0)
objDOM.AppendChild(objNode)
Set objNode = objDOM.createNode(1, "Root", "")
' Read the XML nodes from the Notepad
strHighLevelInfoPath = projectSuite.path & "Inputs\HighLevelInfo.txt"
strText = aqFile.ReadWholeTextFile(strHighLevelInfoPath, 20)
strNodes = "MachineName$%UserName$%Application$%TestingType$%OperatingSystem$%BuildVersion"
strNodesScplit = Split(strNodes, "$%")
' Split the string and add nodes
strSplit = Split(strText, "$%")
Set ObjHighLevel = objDOM.createNode(1, "HighLevelInfo", "")
Set objGrandChildNode = objDOM.createNode(1, strNodesScplit(0), "")
objGrandChildNode.Text = Sys.HostName
ObjHighLevel.appendChild (objGrandChildNode)
For IntCount = 1 to UBound(strSplit)
Set objGrandChildNode = objDOM.createNode(1, strNodesScplit(IntCount), "")
objGrandChildNode.Text = strSplit(IntCount)
ObjHighLevel.appendChild (objGrandChildNode)
Next
Set objGrandChildNode = objDOM.createNode(1, "ExecuteDateTime", "")
objGrandChildNode.Text = Now
ObjHighLevel.appendChild (objGrandChildNode)
objNode.appendChild ObjHighLevel
objDOM.appendChild objNode
Set objNode = Nothing
Call objDOM.save(strPath)
Set objDOM = Nothing
End Function

Answers (3)