RobotStudio event

XML Read

Hello,
 

I am sure it must be easy but......Cry

 

I am trying to read an XML file with RAB builder in vb.Net, the problem is that when I set the instruction ' m_xmlr.Read()' the program jumps to the catch instruction and I get the following error.

 

 

image

 

This is my program code!

 

Imports System.Xml

Dim m_xmlr As XmlTextReader

Sub Read_XML()

  Try

 

    ' Create the XML Reader

    m_xmlr = New XmlTextReader(xmlFile)

 

    ' Read the XML file

    m_xmlr.Read()

  

    ' The rest of the code is not implemented.......

    ..................

    '

Catch ex As Exception

  GTPUMessageBox.Show(Nothing, Nothing, ex.ToString, "Debug", System.Windows.Forms.MessageBoxIcon.Exclamation, System.Windows.Forms.MessageBoxButtons.OK)

End Try


Endsub

 

 

Best Regards,

 

Edwin,

 



Comments

  • Hi,
     

    I found this sample on MSDN, which shows how to configure the XmlReader to be able to access a file on the web (which I know is not what you are doing) ;

     

    " Create the reader.
        Dim reader as XmlTextReader = new XmlTextReader("http://myServer/data/books.xml")

        ' Supply the credentials necessary to access the Web server.
        Dim resolver as XmlUrlResolver = new XmlUrlResolver()
        resolver.Credentials = CredentialCache.DefaultCredentials
        reader.XmlResolver = resolver  
    "

     

    From what I could understand the reader also tries to resolve references to Schemas, specified in the XML file over the web.

     

    Its a long shot, but try to set the XmlTextReader.Resolver to Nothing/Null, and make sure your file path is valid so its not mistaken for a resource on the web for some strange reason.

     

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog
  • Hello,
     

    I am still having the problem. On the VC I can set the path as =>


    objMessages =
    New clsMessages("D:CsiProjects empTest_PM_IzhoraHOMEError_Log_Ru.xml")
    My appl. works perfectly!

     

    Now the problem, what must it be on a real controller? I tried =>

     

    'objMessages = New clsMessages("Error_Log_Ru.xml") ' Does not work!!!!!


    'objMessages = New clsMessages("home:/Error_Log_Ru.xml") ' Werkt niet!!!!!
    'objMessages = New clsMessages("Error_Log_Ru.xml") ' Does not work!!!!!
    'objMessages = New clsMessages("/hd0a/66Z-51925/HOME/Error_Log_Ru.xml") ' Does not work!!!!!
    'objMessages = New clsMessages("/hd0a/66Z-51925/home/Error_Log_Ru.xml") Does not work!!!!!

    What is the correct path name??

     

    Best Regards,

     

     
  • Hi Jaaahh,
     

    the FlexPendant device itself is a separate computer compared to the IRC5 controller.

    So when you write code like "new FileStream(path, FileMode.Open);" the path specified can not be a path on the controller file system.

     

    Basically you have to get the file from the controller to the FlexPendant using the Controller.FileSystem class which provides FTP-like functionality.

    Then you can open the file on the FlexPendant.

    Example:

     

    [CODE]FileStream fs = null;
    if (this._Controller.IsVirtual)
    {
    fs = new FileStream(this._HomeDir + "/mpLocation.mod", FileMode.Open);
    }
    else
    {
    // on the real controller, get the file first
    FileSystem fsys = this._Controller.FileSystem;
    fsys.RemoteDirectory = this._HomeDir;
    fsys.GetFile("mpLocation.mod", "/Temp/" + "mpLocation.mod");
    fs = new FileStream("/Temp/" + "mpLocation.mod", FileMode.Open);
    }
    [/CODE]

     

    There may be a better way to handle the VC/RC issue than the one in my example. I'll check that and come back.

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog
  • Hi guys,

    I want to log the error in to the "Event log".
    I know the list of errors in my applications.
    I would like to create a XML file to list out my all the application errors.
    While running my applications any error occurs, I would like to log in to the event log.
    Which will be helpful for me to trace what happened in the process.
    Guide me. Thank you.
    Lingaa
  • Hi,
     

    do you want your software to create event log entries, or save all entries (or some of them) to an XML file?

     

     

    Best Regards, Niklas Skoglund
    ABB Robotics

    Developer Center
    RobotStudio Blog