N
nicolaspujol
Hi,
GOAL: return in the content of the appropriate xforms:instance node
identified by its id:
I have the following pattern but it is incorrect.
(<xforms:instance.*id=\"services\")(.*)(</xforms:instance>)
It seems to work well up until the (.*) group. For some reason the
parser does not stop at the first occurence of </xforms:instance>
Any thoughts?
=====THE STRING===
<xforms:instance xmlns="" id="nicolas">
<root>
<choice></choice>
</root>
</xforms:instance>
<xforms:instance xmlns="" id="services">
<webservices>
<ws id="1">Zip Code Weather</ws>
<ws id="2">Distance between 2 points</ws>
</webservices>
</xforms:instance>
=====THE CODE=====
strMatch_pattern="
(<xforms:instance.*id=\"services\")(.*)(</xforms:instance>)";
pattern=Pattern.compile(strMatch_pattern,Pattern.DOTALL);
matcher=pattern.matcher(new StringBuffer(p_strForm));
sb=new StringBuffer();
while(matcher.find())
{
System.out.println(matcher.group(1));
System.out.println(matcher.group(2));
System.out.println(matcher.group(3));
}
matcher.appendTail(sb);
GOAL: return in the content of the appropriate xforms:instance node
identified by its id:
I have the following pattern but it is incorrect.
(<xforms:instance.*id=\"services\")(.*)(</xforms:instance>)
It seems to work well up until the (.*) group. For some reason the
parser does not stop at the first occurence of </xforms:instance>
Any thoughts?
=====THE STRING===
<xforms:instance xmlns="" id="nicolas">
<root>
<choice></choice>
</root>
</xforms:instance>
<xforms:instance xmlns="" id="services">
<webservices>
<ws id="1">Zip Code Weather</ws>
<ws id="2">Distance between 2 points</ws>
</webservices>
</xforms:instance>
=====THE CODE=====
strMatch_pattern="
(<xforms:instance.*id=\"services\")(.*)(</xforms:instance>)";
pattern=Pattern.compile(strMatch_pattern,Pattern.DOTALL);
matcher=pattern.matcher(new StringBuffer(p_strForm));
sb=new StringBuffer();
while(matcher.find())
{
System.out.println(matcher.group(1));
System.out.println(matcher.group(2));
System.out.println(matcher.group(3));
}
matcher.appendTail(sb);