Get the values of child tags based on the value of another child tag
up vote
0
down vote
favorite
Assuming that I have a LONGTEXT
column in MySQL that contains the following value
<Parent1>
<Parent2>
<Parent3>
<id>1</id>
<name>Testing 1</name>
<age>10</age>
</Parent3>
<Parent3>
<id>2</id>
<name>Testing 2</name>
<age>5</age>
</Parent3>
</Parent2>
</Parent1>
I want to extract the values for child tags name
and age
where the id
of Parent3
is equal to 2
but I am not quite sure what xpath should I pass to extractValue
in order to achieve this.
Any guidance would be much appreciated.
mysql xml xpath
add a comment |
up vote
0
down vote
favorite
Assuming that I have a LONGTEXT
column in MySQL that contains the following value
<Parent1>
<Parent2>
<Parent3>
<id>1</id>
<name>Testing 1</name>
<age>10</age>
</Parent3>
<Parent3>
<id>2</id>
<name>Testing 2</name>
<age>5</age>
</Parent3>
</Parent2>
</Parent1>
I want to extract the values for child tags name
and age
where the id
of Parent3
is equal to 2
but I am not quite sure what xpath should I pass to extractValue
in order to achieve this.
Any guidance would be much appreciated.
mysql xml xpath
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Assuming that I have a LONGTEXT
column in MySQL that contains the following value
<Parent1>
<Parent2>
<Parent3>
<id>1</id>
<name>Testing 1</name>
<age>10</age>
</Parent3>
<Parent3>
<id>2</id>
<name>Testing 2</name>
<age>5</age>
</Parent3>
</Parent2>
</Parent1>
I want to extract the values for child tags name
and age
where the id
of Parent3
is equal to 2
but I am not quite sure what xpath should I pass to extractValue
in order to achieve this.
Any guidance would be much appreciated.
mysql xml xpath
Assuming that I have a LONGTEXT
column in MySQL that contains the following value
<Parent1>
<Parent2>
<Parent3>
<id>1</id>
<name>Testing 1</name>
<age>10</age>
</Parent3>
<Parent3>
<id>2</id>
<name>Testing 2</name>
<age>5</age>
</Parent3>
</Parent2>
</Parent1>
I want to extract the values for child tags name
and age
where the id
of Parent3
is equal to 2
but I am not quite sure what xpath should I pass to extractValue
in order to achieve this.
Any guidance would be much appreciated.
mysql xml xpath
mysql xml xpath
edited Nov 19 at 15:30
asked Nov 19 at 15:03
Giorgos Myrianthous
3,63121233
3,63121233
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
You can use
//Parent3[id=2]/name/text()
//Parent3[id=2]/age/text()
To extract values of name
and age
children of Parent3
that contain id
equal to 2
add a comment |
up vote
1
down vote
If you want one xpath to get the results I see 2 ways of doing this
1 :
//Parent3[id = 2]/name/text()|//Parent3[id = 2]/age/text()
2 :
//Parent3[id = 2]/*[self::name|self::age]/text()
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can use
//Parent3[id=2]/name/text()
//Parent3[id=2]/age/text()
To extract values of name
and age
children of Parent3
that contain id
equal to 2
add a comment |
up vote
1
down vote
accepted
You can use
//Parent3[id=2]/name/text()
//Parent3[id=2]/age/text()
To extract values of name
and age
children of Parent3
that contain id
equal to 2
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can use
//Parent3[id=2]/name/text()
//Parent3[id=2]/age/text()
To extract values of name
and age
children of Parent3
that contain id
equal to 2
You can use
//Parent3[id=2]/name/text()
//Parent3[id=2]/age/text()
To extract values of name
and age
children of Parent3
that contain id
equal to 2
answered Nov 19 at 15:17
Andersson
35.2k103066
35.2k103066
add a comment |
add a comment |
up vote
1
down vote
If you want one xpath to get the results I see 2 ways of doing this
1 :
//Parent3[id = 2]/name/text()|//Parent3[id = 2]/age/text()
2 :
//Parent3[id = 2]/*[self::name|self::age]/text()
add a comment |
up vote
1
down vote
If you want one xpath to get the results I see 2 ways of doing this
1 :
//Parent3[id = 2]/name/text()|//Parent3[id = 2]/age/text()
2 :
//Parent3[id = 2]/*[self::name|self::age]/text()
add a comment |
up vote
1
down vote
up vote
1
down vote
If you want one xpath to get the results I see 2 ways of doing this
1 :
//Parent3[id = 2]/name/text()|//Parent3[id = 2]/age/text()
2 :
//Parent3[id = 2]/*[self::name|self::age]/text()
If you want one xpath to get the results I see 2 ways of doing this
1 :
//Parent3[id = 2]/name/text()|//Parent3[id = 2]/age/text()
2 :
//Parent3[id = 2]/*[self::name|self::age]/text()
answered Nov 19 at 15:23
Nesku
19519
19519
add a comment |
add a comment |
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%2f53377385%2fget-the-values-of-child-tags-based-on-the-value-of-another-child-tag%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