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
Rashmi kaneriPosted Aug 16, 2016, 11:20 PM
Vinay SinghPosted Aug 16, 2016, 12:59 AM
Syntax for variable declaration in VB.Net is:
Where,
For detail check the linkattributelist is a list of attributes that apply to the variable. Optional.
accessmodifier defines the access levels of the variables, it has values as - Public, Protected, Friend, Protected Friend and Private. Optional.
Shared declares a shared variable, which is not associated with any specific instance of a class or structure, rather available to all the instances of the class or structure. Optional.
Shadows indicate that the variable re-declares and hides an identically named element, or set of overloaded elements, in a base class. Optional.
Static indicates that the variable will retain its value, even when the after termination of the procedure in which it is declared. Optional.
ReadOnly means the variable can be read, but not written. Optional.
WithEvents specifies that the variable is used to respond to events raised by the instance assigned to the variable. Optional.
Variablelist provides the list of variables declared.
Midhun TpPosted Aug 16, 2016, 12:44 AM