취소
다음에 대한 결과 표시 
다음에 대한 검색 
다음을 의미합니까? 

Reading in text file

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.

0 포인트
1/8 메시지
3,582 조회수

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).



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 포인트
2/8 메시지
3,576 조회수

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.

0 포인트
3/8 메시지
3,567 조회수

@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.

0 포인트
4/8 메시지
3,540 조회수

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.

0 포인트
5/8 메시지
3,519 조회수

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).

0 포인트
6/8 메시지
3,512 조회수

Cool, it works. 

 

     <setting name="port" serializeAs="String">
                <value>5678</value>

 

How can I strip off the trailing </value>

0 포인트
7/8 메시지
3,502 조회수

Use the same vi with </value> as the search string.  The port will be the string returned before the search results (top output)

0 포인트
8/8 메시지
3,494 조회수