i need to catch all the text of 1 page, but i want html parser to output it in a list of Strings, not only on 1 String, like GetStrings() method does...
how can i do it ? is there some method to call or i need to modify some source code ?
thx for the help
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you not convert the string returned from getStrings() into a list by breaking it up at each newline?
Altering/rewriting the StringBean to return a list of strings would be a lot more work.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i can split the string using "/n" but its not what i want.
if i have 1 section of the page with more then 2 lines, i want all this section in the same node, but spliting it with "/n" i will have same number of nodes then paragraphs.
for example :
<h2>DESCRIPTION :</h2>
<p>this subject need to ....</p>
<h2>OBJECTIVES</h2>
<p>u need to ...</p>
<p>also u have to ...</p>
parsing this i will have 1 String with :
DESCRIPTION :
this subject need to ....
OBJECTIVES
u need to ...
also u have to ...
and spliting it with "/n" i will have each line in a different String but what i want is to have the last 2 lines together in the same node...
dunno if im explaining fine, hope u can understand me, and sorry for my poor english
thx again
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can re-write the StringBean to do what you want,
but you may be better off just subclassing it and overriding the visitTag method
to inject special strings you can break-up the output with later.
Currently this method is...
/**
* Appends a NEWLINE to the output if the tag breaks flow, and
* possibly sets the state of the PRE and SCRIPT flags.
* @param tag The tag to examine.
*/
public void visitTag (Tag tag)
{
String name;
if (tag instanceof LinkTag)
if (getLinks ())
{ // appends the link as text between angle brackets to the output.
mBuffer.append ("<");
mBuffer.append (((LinkTag)tag).getLink ());
mBuffer.append (">");
}
name = tag.getTagName ();
if (name.equalsIgnoreCase ("PRE"))
mIsPre = true;
else if (name.equalsIgnoreCase ("SCRIPT"))
mIsScript = true;
else if (name.equalsIgnoreCase ("STYLE"))
mIsStyle = true;
if (tag.breaksFlow ())
carriageReturn ();
}
What you might want is:
public class MyStringBean extends StringBean
{
/**
* Appends a NEWLINE to the output if the tag breaks flow, and
* possibly sets the state of the PRE and SCRIPT flags.
* @param tag The tag to examine.
*/
public void visitTag (Tag tag)
{
String name;
if (tag instanceof LinkTag)
if (getLinks ())
{ // appends the link as text between angle brackets to the output.
mBuffer.append ("<");
mBuffer.append (((LinkTag)tag).getLink ());
mBuffer.append (">");
}
name = tag.getTagName ();
if (name.equalsIgnoreCase ("PRE"))
mIsPre = true;
else if (name.equalsIgnoreCase ("SCRIPT"))
mIsScript = true;
else if (name.equalsIgnoreCase ("STYLE"))
mIsStyle = true;
if (tag instanceof HeadingTag)
mBuffer.append ("{my special marker}");
else
if (tag.breaksFlow ())
carriageReturn ();
}
}
Then you break the output from getStrings() at the "{my special marker}" locations.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hi
i need to catch all the text of 1 page, but i want html parser to output it in a list of Strings, not only on 1 String, like GetStrings() method does...
how can i do it ? is there some method to call or i need to modify some source code ?
thx for the help
Can you not convert the string returned from getStrings() into a list by breaking it up at each newline?
Altering/rewriting the StringBean to return a list of strings would be a lot more work.
Hi
thx for the quick reply !
i can split the string using "/n" but its not what i want.
if i have 1 section of the page with more then 2 lines, i want all this section in the same node, but spliting it with "/n" i will have same number of nodes then paragraphs.
for example :
<h2>DESCRIPTION :</h2>
<p>this subject need to ....</p>
<h2>OBJECTIVES</h2>
<p>u need to ...</p>
<p>also u have to ...</p>
parsing this i will have 1 String with :
DESCRIPTION :
this subject need to ....
OBJECTIVES
u need to ...
also u have to ...
and spliting it with "/n" i will have each line in a different String but what i want is to have the last 2 lines together in the same node...
dunno if im explaining fine, hope u can understand me, and sorry for my poor english
thx again
Oh, you want to break the text at certain tags...
You can re-write the StringBean to do what you want,
but you may be better off just subclassing it and overriding the visitTag method
to inject special strings you can break-up the output with later.
Currently this method is...
/**
* Appends a NEWLINE to the output if the tag breaks flow, and
* possibly sets the state of the PRE and SCRIPT flags.
* @param tag The tag to examine.
*/
public void visitTag (Tag tag)
{
String name;
if (tag instanceof LinkTag)
if (getLinks ())
{ // appends the link as text between angle brackets to the output.
mBuffer.append ("<");
mBuffer.append (((LinkTag)tag).getLink ());
mBuffer.append (">");
}
name = tag.getTagName ();
if (name.equalsIgnoreCase ("PRE"))
mIsPre = true;
else if (name.equalsIgnoreCase ("SCRIPT"))
mIsScript = true;
else if (name.equalsIgnoreCase ("STYLE"))
mIsStyle = true;
if (tag.breaksFlow ())
carriageReturn ();
}
What you might want is:
public class MyStringBean extends StringBean
{
/**
* Appends a NEWLINE to the output if the tag breaks flow, and
* possibly sets the state of the PRE and SCRIPT flags.
* @param tag The tag to examine.
*/
public void visitTag (Tag tag)
{
String name;
if (tag instanceof LinkTag)
if (getLinks ())
{ // appends the link as text between angle brackets to the output.
mBuffer.append ("<");
mBuffer.append (((LinkTag)tag).getLink ());
mBuffer.append (">");
}
name = tag.getTagName ();
if (name.equalsIgnoreCase ("PRE"))
mIsPre = true;
else if (name.equalsIgnoreCase ("SCRIPT"))
mIsScript = true;
else if (name.equalsIgnoreCase ("STYLE"))
mIsStyle = true;
if (tag instanceof HeadingTag)
mBuffer.append ("{my special marker}");
else
if (tag.breaksFlow ())
carriageReturn ();
}
}
Then you break the output from getStrings() at the "{my special marker}" locations.
really thx for the help
it was useful, and im now having the output like i want.
thx again !