# Is it possible to read an htm or html file as a string?

**URL:** <https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355>\
**Category:** Ignition\
**Created:** [January 16, 2020, 10:56pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355 "2020-01-16T22:56:25Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [January 16, 2020, 10:56pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/1 "2020-01-16T22:56:25Z")

</div>

I need to figure out if this is possible before I commit time to it. I have htm files that are used in a .net application for CNC machines. Somehow they use them to render up things in their thing. When I open in a text editor I get something like the following:

```auto
<HTML>
<HEAD>
<TITLE>Fault Tags</TITLE>
</HEAD>
<BODY>

<H1 ALIGN = CENTER>Fault Tags</H1>

<BR><HR><H3 ALIGN = CENTER>INTRODUCTION</H3>

<H4 align="center">FAULTS</H4>

<p>&nbsp;</p>

<p>
<HR><A NAME = "D"></A>
Delay Faults<br>
<HR><A NAME = "D1"></A>
D1 HYDRAULIC PRESSURE ALARM<br>
FLT.D_FLT[0].0<br>
Fault: The system has excessive backpressure in one of the hydraulic filters.&nbsp;<br>
Action: Check power pack return and supply filters and replace as necessary.
<br>
<p><img border="0" src="FLT.D_FLT[0].0.jpg" width="600" height="600">
<br>
</p>
<HR><A NAME = "D2"></A>
D2 TABLE DID NOT LIFT UP<br>
FLT.D_FLT[0].1<br>
Fault: The Table Down prox did not turn off, or the Table Up prox did not turn<br>
 on when the Table Up solenoid was energized during the last table index<br>
 sequence.&nbsp;<br>
Action: Check prox switch and solenoid operation and adjust, repair or replace as needed.<br>
<br>
<p><img border="0" src="FLT.D_FLT[0].1.jpg" width="600" height="600">
<p><img border="0" src="FLT.D_FLT[0].11.jpg" width="600" height="500">

```

When I try to read it through a console it throws:

```auto
Traceback (most recent call last):
  File "<input>", line 2, in <module>
IOError: File 'P:\will\Gage\FaultTagsD.htm' doesn't exist or isn't a file.

```

I also saved it as HTML and the same results. As a sanity check. After researching seems like there isn’t much diff.

Eventually, the goal would be to read it and output:

```auto
D1 HYDRAULIC PRESSURE ALARM
FLT.D_FLT[0].0
Fault: The system has excessive backpressure in one of the hydraulic filters.&nbsp
Action: Check power pack return and supply filters and replace as necessary.

```

In some way. To store. I can figure out that bit if it is possible to read?  
Or maybe place them in the web apps folder and scrape?  
Or give up and have interns make it manually next summer?

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 16, 2020, 11:27pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/2 "2020-01-16T23:27:08Z")

</div>

Sure you can.

 ![html%20file%20as%20string](https://us1.discourse-cdn.com/inductiveautomation/original/2X/d/d28f70f93225f163e06620fc2353b2ee568006ec.png)

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 16, 2020, 11:28pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/3 "2020-01-16T23:28:43Z")

</div>

Tested and working for HTM extension too

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [January 16, 2020, 11:33pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/4 "2020-01-16T23:33:02Z")

</div>

Right on, thanks man!

I figured it could.

So it’s gotta be an access problem. I’m confused on what scope the script console is ran in. It is using the mapped drive of server or my machine. But, we’ll get er figured out. I have same drive mapped to different letters lol on the machines. Although I cant get either to work rn

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 16, 2020, 11:33pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/5 "2020-01-16T23:33:41Z")

</div>

Scripts from the console run on the same machine as the Designer you’re running it in. Make sure the path/file you access is readable from your machine in that case.

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [January 16, 2020, 11:34pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/6 "2020-01-16T23:34:48Z")

</div>

You may need to add the mapped drive into the Ignition conf file.

There is a section in the user manual that details this, and also search this forum if stuck there are several posts on the topic.

Don’t forget in your path to double up all your backslashes as seen in my attachment.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 16, 2020, 11:35pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/7 "2020-01-16T23:35:14Z")

</div>

> [@Matrix\_Engineering](#):
>
> You may need to add the mapped drive into the Ignition conf file.

This is necessary if accessing the file in a script running in gateway scope.

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [January 16, 2020, 11:41pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/8 "2020-01-16T23:41:40Z")

</div>

Yeah, I have did this and seems to be working fine. Its something else. I have similar things working already…

I added hashes in front of the edits. And didn’t find anything in the logs. Don’t know how to prove it other than that and testing from console.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 16, 2020, 11:48pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/9 "2020-01-16T23:48:38Z")

</div>

Are you using sufficient backslashes in the path, as per @Matrix_Engineering’s example?

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [January 16, 2020, 11:52pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/10 "2020-01-16T23:52:03Z")

</div>

It is running on my local machine accessing my mapped drives on my local machine:

I did a bunch of work earlier thinking I was using the mapped drive of the server not paying a ton of attention to file paths. It was just working. I was confused as P: is Z: and vice versa… 🙄

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [January 16, 2020, 11:56pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/11 "2020-01-16T23:56:22Z")

</div>

![1](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/40ce3f56a30e26b256c1e191d0ff4d036a1f3d9f.jpeg)

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [January 17, 2020, 12:35am UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/12 "2020-01-17T00:35:19Z")

</div>

To avoid this problem when hard coding the path, you could always use the \domain\folder\path style.

So instead of using P: or Z: you would have ‘//Domain\_or\_server/Folder/’ an example would be “\\EPIC-FILESVR\Shared\will\Gage\FaultTagsD.htm”

This is what I use as it guarantees you point to the correct location regardless of what machine it’s used on. You only have to make sure that the user running the script has rights to access the shared drive.

---

<div class="post-metadata">

**Author:** ![wking](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wking/32/21823_2.png) [@wking](https://forum.inductiveautomation.com/u/wking)\
**Post date:** [January 17, 2020, 1:01am UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-read-an-htm-or-html-file-as-a-string/31355/13 "2020-01-17T01:01:51Z")

</div>

Nice.

So that works from console nicely:

 ![1](https://us1.discourse-cdn.com/inductiveautomation/original/2X/9/9b19b422f13c0a11a9f0306bdd8b59b26312a78f.jpeg)

Can’t tell if it’ll work from gateway yet. Trying to figure out how to get my global scripting project to work. For that. Then I can confirm if the drive is mapped in ignition. One step at a time. Thanks man!
