04-29-2013 12:33 PM
I have a text file that contains something like this:
<setting name="ip_address" serializeAs="String">
<value>239.0.0.1</value>
I want to be able to search through the text file and based upon finding <setting name="ip_address" serializeAs="String">, I'd like to get the 239.0.0.1
New to Labview. So I'm not sure how to do it. Currently using LabView 2012. Thanks.
04-29-2013 12:43 PM
That looks a lot like XML. You might want to look at the few XML examples in the LabVIEW Example Finder (do a search for XML in the Example Finder).
04-29-2013 01:21 PM
It is xml, but it doesn't have the xml extention. From what I've seen, the .xml is required. I'm currently using read from text file, but can't figure out how to do the search.
04-29-2013 03:45 PM - edited 04-29-2013 03:47 PM
@Sebastian2011 wrote:
I have a text file that contains something like this:
<setting name="ip_address" serializeAs="String">
<value>239.0.0.1</value>
I want to be able to search through the text file and based upon finding <setting name="ip_address" serializeAs="String">, I'd like to get the 239.0.0.1
New to Labview. So I'm not sure how to do it. Currently using LabView 2012. Thanks.
Generally, your txt file will be read in as a spreadsheet string or as an array of strings.
You can use Match Pattern to look for <setting name="ip_address" serializeAs="String">\r<value>
Three outputs will contain the text leading up to the search string, the search string, and the rest (the rest will contain the ip_address followed by the rest of the text file),
Use Match Pattern again looking for </value> that comes after the ip_address. The first output will contain the ip_address.
04-30-2013 12:07 PM
Thansks for the help. When I enter <setting name="port" serializeAs="String"> it finds the string, but when I enter <setting name="port" serializeAs="String">\r<value> it does not find it.
04-30-2013 12:45 PM
Copy/paste that section of text from the file into a string constant. (I may have missed some tab characters or was incorrect in how I added the return character).
04-30-2013 03:04 PM
Cool, it works.
<setting name="port" serializeAs="String">
<value>5678</value>
How can I strip off the trailing </value>
04-30-2013 03:47 PM - edited 04-30-2013 03:48 PM
Use the same vi with </value> as the search string. The port will be the string returned before the search results (top output)