xpath regular expression for xml
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I would like to read an xml using xpath regular expression.
The tags can be <PaymentCard>
or <ns2:PaymentCard>
.
I need to find a common regular expression to read both of the tags.
Currently I am able to read only <PaymentCard>
tag using below code:
paymentCardPath = xpath.compile("//PaymentCard");
java xml xslt xpath
add a comment |
I would like to read an xml using xpath regular expression.
The tags can be <PaymentCard>
or <ns2:PaymentCard>
.
I need to find a common regular expression to read both of the tags.
Currently I am able to read only <PaymentCard>
tag using below code:
paymentCardPath = xpath.compile("//PaymentCard");
java xml xslt xpath
There's no regular expression involved.
– choroba
Jan 3 at 6:19
1
Is it reallyns2.PaymentCard
or actuallyns2:PaymentCard
?
– Tim C
Jan 3 at 8:09
In XPath 2.0 you can use//*[matches(name(), 'PaymentCard')]
or//*[ends-with(name(), 'PaymentCard')]
– Andersson
Jan 3 at 8:45
its actually ns2:PaymentCard
– Amar
Jan 3 at 10:15
add a comment |
I would like to read an xml using xpath regular expression.
The tags can be <PaymentCard>
or <ns2:PaymentCard>
.
I need to find a common regular expression to read both of the tags.
Currently I am able to read only <PaymentCard>
tag using below code:
paymentCardPath = xpath.compile("//PaymentCard");
java xml xslt xpath
I would like to read an xml using xpath regular expression.
The tags can be <PaymentCard>
or <ns2:PaymentCard>
.
I need to find a common regular expression to read both of the tags.
Currently I am able to read only <PaymentCard>
tag using below code:
paymentCardPath = xpath.compile("//PaymentCard");
java xml xslt xpath
java xml xslt xpath
edited Jan 3 at 18:57


Daniel Haley
39.7k45481
39.7k45481
asked Jan 3 at 6:17
AmarAmar
1631312
1631312
There's no regular expression involved.
– choroba
Jan 3 at 6:19
1
Is it reallyns2.PaymentCard
or actuallyns2:PaymentCard
?
– Tim C
Jan 3 at 8:09
In XPath 2.0 you can use//*[matches(name(), 'PaymentCard')]
or//*[ends-with(name(), 'PaymentCard')]
– Andersson
Jan 3 at 8:45
its actually ns2:PaymentCard
– Amar
Jan 3 at 10:15
add a comment |
There's no regular expression involved.
– choroba
Jan 3 at 6:19
1
Is it reallyns2.PaymentCard
or actuallyns2:PaymentCard
?
– Tim C
Jan 3 at 8:09
In XPath 2.0 you can use//*[matches(name(), 'PaymentCard')]
or//*[ends-with(name(), 'PaymentCard')]
– Andersson
Jan 3 at 8:45
its actually ns2:PaymentCard
– Amar
Jan 3 at 10:15
There's no regular expression involved.
– choroba
Jan 3 at 6:19
There's no regular expression involved.
– choroba
Jan 3 at 6:19
1
1
Is it really
ns2.PaymentCard
or actually ns2:PaymentCard
?– Tim C
Jan 3 at 8:09
Is it really
ns2.PaymentCard
or actually ns2:PaymentCard
?– Tim C
Jan 3 at 8:09
In XPath 2.0 you can use
//*[matches(name(), 'PaymentCard')]
or //*[ends-with(name(), 'PaymentCard')]
– Andersson
Jan 3 at 8:45
In XPath 2.0 you can use
//*[matches(name(), 'PaymentCard')]
or //*[ends-with(name(), 'PaymentCard')]
– Andersson
Jan 3 at 8:45
its actually ns2:PaymentCard
– Amar
Jan 3 at 10:15
its actually ns2:PaymentCard
– Amar
Jan 3 at 10:15
add a comment |
2 Answers
2
active
oldest
votes
In a supplementary comment you clarified that the two names in question are actually PaymentCard
and ns2:PaymentCard
- that is, two names that have the same local part and different namespace URIs.
In XPath 2.0 you can find names using the local part alone using //*:PaymentCard
. The XPath 1.0 equivalent is //*[local-name()='PaymentCard']
.
1
Though strictly speaking that will also findns1:PaymentCard
.
– michael.hor257k
Jan 3 at 13:27
add a comment |
Use the union operator:
//*[self::PaymentCard | self::ns2.PaymentCard]
Note that's an XPath Expression (version 1.0), not a regular expression.
add a comment |
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%2f54017205%2fxpath-regular-expression-for-xml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
In a supplementary comment you clarified that the two names in question are actually PaymentCard
and ns2:PaymentCard
- that is, two names that have the same local part and different namespace URIs.
In XPath 2.0 you can find names using the local part alone using //*:PaymentCard
. The XPath 1.0 equivalent is //*[local-name()='PaymentCard']
.
1
Though strictly speaking that will also findns1:PaymentCard
.
– michael.hor257k
Jan 3 at 13:27
add a comment |
In a supplementary comment you clarified that the two names in question are actually PaymentCard
and ns2:PaymentCard
- that is, two names that have the same local part and different namespace URIs.
In XPath 2.0 you can find names using the local part alone using //*:PaymentCard
. The XPath 1.0 equivalent is //*[local-name()='PaymentCard']
.
1
Though strictly speaking that will also findns1:PaymentCard
.
– michael.hor257k
Jan 3 at 13:27
add a comment |
In a supplementary comment you clarified that the two names in question are actually PaymentCard
and ns2:PaymentCard
- that is, two names that have the same local part and different namespace URIs.
In XPath 2.0 you can find names using the local part alone using //*:PaymentCard
. The XPath 1.0 equivalent is //*[local-name()='PaymentCard']
.
In a supplementary comment you clarified that the two names in question are actually PaymentCard
and ns2:PaymentCard
- that is, two names that have the same local part and different namespace URIs.
In XPath 2.0 you can find names using the local part alone using //*:PaymentCard
. The XPath 1.0 equivalent is //*[local-name()='PaymentCard']
.
answered Jan 3 at 10:19


Michael KayMichael Kay
112k663119
112k663119
1
Though strictly speaking that will also findns1:PaymentCard
.
– michael.hor257k
Jan 3 at 13:27
add a comment |
1
Though strictly speaking that will also findns1:PaymentCard
.
– michael.hor257k
Jan 3 at 13:27
1
1
Though strictly speaking that will also find
ns1:PaymentCard
.– michael.hor257k
Jan 3 at 13:27
Though strictly speaking that will also find
ns1:PaymentCard
.– michael.hor257k
Jan 3 at 13:27
add a comment |
Use the union operator:
//*[self::PaymentCard | self::ns2.PaymentCard]
Note that's an XPath Expression (version 1.0), not a regular expression.
add a comment |
Use the union operator:
//*[self::PaymentCard | self::ns2.PaymentCard]
Note that's an XPath Expression (version 1.0), not a regular expression.
add a comment |
Use the union operator:
//*[self::PaymentCard | self::ns2.PaymentCard]
Note that's an XPath Expression (version 1.0), not a regular expression.
Use the union operator:
//*[self::PaymentCard | self::ns2.PaymentCard]
Note that's an XPath Expression (version 1.0), not a regular expression.
answered Jan 3 at 6:21
chorobachoroba
159k14142209
159k14142209
add a comment |
add a comment |
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.
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%2f54017205%2fxpath-regular-expression-for-xml%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
There's no regular expression involved.
– choroba
Jan 3 at 6:19
1
Is it really
ns2.PaymentCard
or actuallyns2:PaymentCard
?– Tim C
Jan 3 at 8:09
In XPath 2.0 you can use
//*[matches(name(), 'PaymentCard')]
or//*[ends-with(name(), 'PaymentCard')]
– Andersson
Jan 3 at 8:45
its actually ns2:PaymentCard
– Amar
Jan 3 at 10:15