PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, October 15, 2022

[FIXED] How to implement siblings nodes (XPATH expressions) relation in Java using DOM and XALAN processor

 October 15, 2022     dom, java, xalan, xpath     No comments   

Issue

Hello everyone I am developing a program in Java to read the XML using XPATH for siblings nodes (elements which are same level)

I am not able to implement below XPATH expression in Java:

//*:root/*:child1[.='child_value']/following-sibling::*:child2[*:subelement]/*:subelement3/*:subelement4/following-sibling::*:anyelement

Could any one please suggest any solution


Solution

The construct *:root requires XPath 2.0, which isn't supported by Xalan. The simplest solution is to use Saxon instead.

In XPath 1.0 the way to select an element by local name alone is *[local-name()='root'] which gets a bit cumbersome for an expression like this that includes 7 such selections.



Answered By - Michael Kay
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing