# XML Read

**URL:** <https://tech-community.robotics.abb.com/t/xml-read/3471>\
**Category:** Developer Tools\
**Created:** [March 25, 2010, 5:14pm UTC](https://tech-community.robotics.abb.com/t/xml-read/3471 "2010-03-25T17:14:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaaahhh](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@Jaaahhh](https://tech-community.robotics.abb.com/u/Jaaahhh)\
**Post date:** [March 25, 2010, 5:14pm UTC](https://tech-community.robotics.abb.com/t/xml-read/3471/1 "2010-03-25T17:14:01Z")

</div>

Hello,

I am sure it must be easy but…:grinning:

I am trying to read an XML file with RAB builder in [vb.Net](http://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.

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,

---

<div class="post-metadata">

**Author:** ![Niklas\_Skoglund](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@Niklas\_Skoglund](https://tech-community.robotics.abb.com/u/Niklas_Skoglund)\
**Post date:** [March 25, 2010, 5:51pm UTC](https://tech-community.robotics.abb.com/t/xml-read/3471/2 "2010-03-25T17:51:12Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![Jaaahhh](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@Jaaahhh](https://tech-community.robotics.abb.com/u/Jaaahhh)\
**Post date:** [March 30, 2010, 5:18pm UTC](https://tech-community.robotics.abb.com/t/xml-read/3471/3 "2010-03-30T17:18:34Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![Niklas\_Skoglund](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@Niklas\_Skoglund](https://tech-community.robotics.abb.com/u/Niklas_Skoglund)\
**Post date:** [March 31, 2010, 7:09pm UTC](https://tech-community.robotics.abb.com/t/xml-read/3471/4 "2010-03-31T19:09:00Z")

</div>

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:

`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);
}`

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.

---

<div class="post-metadata">

**Author:** ![Lin](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/lin/32/2104_2.png) [@Lin](https://tech-community.robotics.abb.com/u/Lin)\
**Post date:** [September 8, 2010, 2:01pm UTC](https://tech-community.robotics.abb.com/t/xml-read/3471/5 "2010-09-08T14:01:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Niklas\_Skoglund](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@Niklas\_Skoglund](https://tech-community.robotics.abb.com/u/Niklas_Skoglund)\
**Post date:** [September 20, 2010, 10:48am UTC](https://tech-community.robotics.abb.com/t/xml-read/3471/6 "2010-09-20T10:48:25Z")

</div>

Hi,

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