How to output html text using fscanf or textscan

1 次查看(过去 30 天)
Greetings,
I'm trying to take a specified data from a html text using MATLAB.
Here is a sample html text(lines 12-18):
<FONT SIZE=+1 COLOR="#800000">TONIGHT</FONT>
EAST WINDS 10 TO 15 KNOTS. SEAS 3 TO 4 FEET. ISOLATED
SHOWERS.
<FONT SIZE=+1 COLOR="#800000">SATURDAY</FONT>
EAST WINDS 12 TO 16 KNOTS. SEAS 3 TO 4 FEET. ISOLATED
SHOWERS.
I want to take the headings 'Tonight' and 'Saturday' (Line 12 and 18) thus the data 'EAST WINDS 10 TO 15 KNOTS. SEAS 3 TO 4 FEET. ISOLATED SHOWERS.' and 'EAST WINDS 12 TO 16 KNOTS. SEAS 3 TO 4 FEET. ISOLATED SHOWERS. ' leaving me with an output of:
TONIGHT
EAST WINDS 10 TO 15 KNOTS. SEAS 3 TO 4 FEET. ISOLATED
SHOWERS.
SATURDAY
EAST WINDS 12 TO 16 KNOTS. SEAS 3 TO 4 FEET. ISOLATED
SHOWERS.
I want to use textscan or fscanf to make MATLAB scan the text file and leave me an output of just the plain text without de html tags.
Thank you for your time

采纳的回答

Walter Roberson
Walter Roberson 2012-6-30
Well if it is important to use textscan() or fscanf(), then:
DataCell = textscan( fid, '%s', 'Delimiter', ''); %read the entire file as strings, one per line.
Output = regexprep( DataCell, '<[^>]+>', '' ); %remove the HTML
This will be a cell array of strings.
  3 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Large Files and Big Data 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by