0

I've been battling trying to extract values from a node name and attribute value using xpath with xml. I've searched on this many times but not found anything about my particular issue of String= being part of the returned output.

I thought I had the syntax correct, but somehow while trying to extract values through xpath I am getting String='value' instead of just value.

When I try

string(/Data/child::object1/string(@display_value))

The output is String='482899' whereas I had hoped for 482899 (or '482899'). Similarly with this:

name(/Data/child::object1)

That's return String='object1'.

The XML I am working with is static (I cannot edit its format, which is part of why I have such tortured xpath). Below is a partial sample of the XML:

<?xml version="1.0"?>
<Data>
    <object1 display_value="482899" />
    <object2 display_value="61317 " />
</Data>

Any help or guidance would be appreciated.

2
  • 1
    string just shows the type of output. How do you run your code? I am sure you can turn off the output type in your program. Commented Dec 1, 2016 at 16:54
  • Floo0 and kjhughes are right -- String= is not coming from the XPath. It's coming from the environment (e.g. programming language) that you're evaluating the XPath with. Tell us about that environment and someone can doubtless help you fix it. Commented Dec 1, 2016 at 16:59

1 Answer 1

2

String= is not part of what XPath itself is selecting. Rather, it's just the user interface to the particular XPath library you're using trying to be helpful in identifying that you've selected a string as opposed to an element, attribute, etc.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.