using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Xml.Linq;
using System.Text;
using System.Windows.Forms;
namespace NAE_BACNet_Object_Change
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void btnConvert_Click(object sender, EventArgs e)
{
XElement XObjectsElements = XElement.Load(@"export.xml");
lstLog.Clear();
string strFullReference = "";
string strObjectName = "";
foreach (XElement XObjectElement in XObjectsElements.Nodes().OfType<XElement>())
{
if ((string)XObjectElement.Attribute("classid") == "502" | (string)XObjectElement.Attribute("classid") == "519")
{
foreach (XElement XPropertyElement in XObjectElement.Nodes().OfType<XElement>())
{
if ((string)XPropertyElement.Attribute("id") == "2390") { strObjectName = XPropertyElement.Value; }
if ((string)XPropertyElement.Attribute("id") == "32527")
{
strFullReference = XPropertyElement.Value;
int lastDotPosition = strFullReference.LastIndexOf('.');
string strNode = strFullReference.Substring(0, lastDotPosition);
string strObject = strFullReference.Substring(lastDotPosition + 1, strFullReference.Length - lastDotPosition - 1);
if (lastDotPosition != -1 && strObjectName != strObject)
{
lstLog.AppendText(String.Format("{0} -> {1}.{2}{3}", XPropertyElement.Value, strNode, strObjectName, Environment.NewLine));
XPropertyElement.SetValue(strNode + strObjectName);
}
else
{
lstLog.AppendText(String.Format("{0} -> {1}{2}", XPropertyElement.Value, "No Chnage", Environment.NewLine));
}
}
}
}
}
XObjectsElements.Save(@"export.xml");
}
}
}
export-original.xmlExperts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE