Sample code for 30+ languages & platforms
Java

SearchAllForContent

See more XML Examples

Demonstrates the SearchAllForContent method.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

    CkXml xml = new CkXml();
    CkXml xBeginAfter;
    CkXml xFound;

    success = xml.LoadXmlFile("qa_data/xml/pigs.xml");
    if (success != true) {
        System.out.println(xml.lastErrorText());
        return;
        }

    xBeginAfter = xml.GetSelf();
    xFound = xml.SearchAllForContent(xBeginAfter,"*pig*");
    boolean searchForMore = true;
    while ((searchForMore == true)) {

        System.out.println(xFound.tag());
        System.out.println(xFound.content());
        System.out.println("--");

        xBeginAfter = xFound;
        xFound = xml.SearchAllForContent(xBeginAfter,"*pig*");

        searchForMore = xml.get_LastMethodSuccess();
        }
  }
}