Issues retrieving repeated child nodes using XPath using Java
I have the below structure where parent nodes are repeating nodes - lets say 5 nodes. Within these 5 parent nodes, I have 5 repeating child nodes with 5 attributes. I need to retrieve the values of attributes depending upon the value of the attribute.
Lets say one of the attribute values is "Credit card"
for one of the rows and for the other 4 rows value of the attribute value is "Debit card"
. When the value == "Credit card"
, I need to take the values of the other attributes. I have tested that only one row exists for attribute value == "Credit card"
and at least one row exists for the attribute value == "Debit card"
So basically I need to get a hold of the 5 child nodes for each instance of the parent.
I am able to retrieve the 5 instance of parent nodes with the right XPath, but I retrieve the child nodes using the getchild()
method, but I get child nodes as 25 (in case if we have 5 parent nodes - 5 * 5) but instead of 5 nodes. Basically, I am unable to get a hold of child nodes (count 5) . Whatever way I use, I always retrieve all child nodes under all parent nodes, instead of a particular parent node.
<Parent1>
<child1>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child1>
<child2>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child2>
<child3>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child3>
<child4>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child4>
<child5>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child5>
</Parent1>
<Parent2>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent2>
<Parent2>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent3>
<Parent4>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent4>
<Parent5>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent5>
java xpath
add a comment |
I have the below structure where parent nodes are repeating nodes - lets say 5 nodes. Within these 5 parent nodes, I have 5 repeating child nodes with 5 attributes. I need to retrieve the values of attributes depending upon the value of the attribute.
Lets say one of the attribute values is "Credit card"
for one of the rows and for the other 4 rows value of the attribute value is "Debit card"
. When the value == "Credit card"
, I need to take the values of the other attributes. I have tested that only one row exists for attribute value == "Credit card"
and at least one row exists for the attribute value == "Debit card"
So basically I need to get a hold of the 5 child nodes for each instance of the parent.
I am able to retrieve the 5 instance of parent nodes with the right XPath, but I retrieve the child nodes using the getchild()
method, but I get child nodes as 25 (in case if we have 5 parent nodes - 5 * 5) but instead of 5 nodes. Basically, I am unable to get a hold of child nodes (count 5) . Whatever way I use, I always retrieve all child nodes under all parent nodes, instead of a particular parent node.
<Parent1>
<child1>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child1>
<child2>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child2>
<child3>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child3>
<child4>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child4>
<child5>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child5>
</Parent1>
<Parent2>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent2>
<Parent2>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent3>
<Parent4>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent4>
<Parent5>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent5>
java xpath
Kindly suggest how can we handle xpath using java. I wish to avoid using xmlapth as I have already done 99% of my code using xpath . I wish to avoid to switching to xmlpath .I would be thankful for solution towards this issue.
– aditya mandlekar
Nov 23 '18 at 2:36
XML structure incase its not posted incorrectly above:<Parent1> <child1>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child1> <child2>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child2> <child3>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child3> <child4>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child4>
– aditya mandlekar
Nov 23 '18 at 2:40
add a comment |
I have the below structure where parent nodes are repeating nodes - lets say 5 nodes. Within these 5 parent nodes, I have 5 repeating child nodes with 5 attributes. I need to retrieve the values of attributes depending upon the value of the attribute.
Lets say one of the attribute values is "Credit card"
for one of the rows and for the other 4 rows value of the attribute value is "Debit card"
. When the value == "Credit card"
, I need to take the values of the other attributes. I have tested that only one row exists for attribute value == "Credit card"
and at least one row exists for the attribute value == "Debit card"
So basically I need to get a hold of the 5 child nodes for each instance of the parent.
I am able to retrieve the 5 instance of parent nodes with the right XPath, but I retrieve the child nodes using the getchild()
method, but I get child nodes as 25 (in case if we have 5 parent nodes - 5 * 5) but instead of 5 nodes. Basically, I am unable to get a hold of child nodes (count 5) . Whatever way I use, I always retrieve all child nodes under all parent nodes, instead of a particular parent node.
<Parent1>
<child1>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child1>
<child2>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child2>
<child3>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child3>
<child4>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child4>
<child5>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child5>
</Parent1>
<Parent2>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent2>
<Parent2>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent3>
<Parent4>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent4>
<Parent5>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent5>
java xpath
I have the below structure where parent nodes are repeating nodes - lets say 5 nodes. Within these 5 parent nodes, I have 5 repeating child nodes with 5 attributes. I need to retrieve the values of attributes depending upon the value of the attribute.
Lets say one of the attribute values is "Credit card"
for one of the rows and for the other 4 rows value of the attribute value is "Debit card"
. When the value == "Credit card"
, I need to take the values of the other attributes. I have tested that only one row exists for attribute value == "Credit card"
and at least one row exists for the attribute value == "Debit card"
So basically I need to get a hold of the 5 child nodes for each instance of the parent.
I am able to retrieve the 5 instance of parent nodes with the right XPath, but I retrieve the child nodes using the getchild()
method, but I get child nodes as 25 (in case if we have 5 parent nodes - 5 * 5) but instead of 5 nodes. Basically, I am unable to get a hold of child nodes (count 5) . Whatever way I use, I always retrieve all child nodes under all parent nodes, instead of a particular parent node.
<Parent1>
<child1>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child1>
<child2>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child2>
<child3>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child3>
<child4>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child4>
<child5>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child5>
</Parent1>
<Parent2>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent2>
<Parent2>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent3>
<Parent4>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent4>
<Parent5>
<child1>
<child2>
<child3>
<child4>
<child5>
</Parent5>
java xpath
java xpath
edited Nov 23 '18 at 4:05
Mihai Chelaru
2,14091022
2,14091022
asked Nov 23 '18 at 2:31
aditya mandlekar
1
1
Kindly suggest how can we handle xpath using java. I wish to avoid using xmlapth as I have already done 99% of my code using xpath . I wish to avoid to switching to xmlpath .I would be thankful for solution towards this issue.
– aditya mandlekar
Nov 23 '18 at 2:36
XML structure incase its not posted incorrectly above:<Parent1> <child1>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child1> <child2>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child2> <child3>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child3> <child4>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child4>
– aditya mandlekar
Nov 23 '18 at 2:40
add a comment |
Kindly suggest how can we handle xpath using java. I wish to avoid using xmlapth as I have already done 99% of my code using xpath . I wish to avoid to switching to xmlpath .I would be thankful for solution towards this issue.
– aditya mandlekar
Nov 23 '18 at 2:36
XML structure incase its not posted incorrectly above:<Parent1> <child1>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child1> <child2>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child2> <child3>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child3> <child4>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child4>
– aditya mandlekar
Nov 23 '18 at 2:40
Kindly suggest how can we handle xpath using java. I wish to avoid using xmlapth as I have already done 99% of my code using xpath . I wish to avoid to switching to xmlpath .I would be thankful for solution towards this issue.
– aditya mandlekar
Nov 23 '18 at 2:36
Kindly suggest how can we handle xpath using java. I wish to avoid using xmlapth as I have already done 99% of my code using xpath . I wish to avoid to switching to xmlpath .I would be thankful for solution towards this issue.
– aditya mandlekar
Nov 23 '18 at 2:36
XML structure incase its not posted incorrectly above:<Parent1> <child1>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child1> <child2>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child2> <child3>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child3> <child4>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child4>
– aditya mandlekar
Nov 23 '18 at 2:40
XML structure incase its not posted incorrectly above:<Parent1> <child1>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child1> <child2>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child2> <child3>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child3> <child4>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child4>
– aditya mandlekar
Nov 23 '18 at 2:40
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439988%2fissues-retrieving-repeated-child-nodes-using-xpath-using-java%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53439988%2fissues-retrieving-repeated-child-nodes-using-xpath-using-java%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Kindly suggest how can we handle xpath using java. I wish to avoid using xmlapth as I have already done 99% of my code using xpath . I wish to avoid to switching to xmlpath .I would be thankful for solution towards this issue.
– aditya mandlekar
Nov 23 '18 at 2:36
XML structure incase its not posted incorrectly above:<Parent1> <child1>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child1> <child2>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child2> <child3>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child3> <child4>"Attribute-1"=Value "Attribute-2"=Value2 "Attribute-3"="Value3" "Attribute-4"=Value2 "Attribute-5"=Value2</child4>
– aditya mandlekar
Nov 23 '18 at 2:40