Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9007991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:50:11+00:00 2026-06-16T01:50:11+00:00

XML File: <apps> <app name=google> <branches> <branch location=us> <datacenters> <datacenter city=Mayes County /> <datacenter

  • 0

XML File:

<apps>
        <app name="google">
              <branches> 
                   <branch location="us">
                       <datacenters>
                               <datacenter city="Mayes County" />
                                <datacenter city="Douglas County" />
                       </datacenters>
                   </branch>
              </branches>
        </app>
        <app name="facebook">
        </app>
</apps>

Java Code:

XPath xpath = XPathFactory.newInstance().newXPath();
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(file);
String expression = "/apps/app[name='google']";
Element element = xpath.evaluvate(expression,document.getDocumentElement();
Element app = (Element)xpath.evaluvate(expression,element,XPathConstants.NODE);

I can able to store the app element and execute the xpath expression within the app element . Like this

xpath.evaluvate("branches/branch[@location='us']",app,XPathConstants.STRING);

How can I do this in VTD XML?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:50:13+00:00Added an answer on June 16, 2026 at 1:50 am

    I think you can learn the API by visiting VTD-XML’s sourceforge web site. Below is what I think how it will look like:

    VTDGen vg = new VTDGen();
    String filename ="this.xml";
    if (vg.parseFile(filename, true)){
        VTDNav vn = vg.getNav();
        AutoPilot ap = new AutoPilot(vn);
        ap.selectXPath("/apps/app[name='google']");
        int i=-1;
        while((i=ap.evalXPath())!=-1){
             //do something with i, it is the node index
        }
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file that looks like <?xml version=1.0> <playlist> <name>My Playlist</name> <song>
I usually use one preference XML file to store all app-wide data. Now I
I am a newbie in creating Google Hangouts and using the XML file and
my app downloads and parses an xml file that contains German Umlauts (ä, ö,
My app needs to open an Access mdb file and an xml file (which
Our JBoss server.xml file has this line: <Engine name=jboss.web defaultHost=localhost jvmRoute=app_server_01> Is there any
Here is what i have in my map.xml file: <com.google.android.maps.MapView android:id=@+id/mapView android:layout_width=fill_parent android:layout_height=fill_parent android:enabled=true
my sitemap.xml file is showing every url of my apps as it should do.
I use iCloud to sync an user xml file between devices in my apps,
XML File Sample <GateDocument> <GateDocumentFeatures> ... </GateDocumentFeatures> <TextWithNodes> <Node id=0/> MESSAGE SET <Node id=19/>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.