2

I met a problem when I wanted to get style attribute of element.

$styleValue = $this->getAttribute("//ul@style");

But result of var_dump($styleValue) is

string(1) ";"

But I expected "margin-left: -2432px;" So, where am I wrong? How can I get style attribute of element?

2
  • 1
    Do your ul elements all have the same style attribute? Commented Nov 14, 2013 at 4:33
  • it's only an example. I have another xpath that return only one ul element. Commented Nov 14, 2013 at 7:39

1 Answer 1

1

Your XPath expression is wrong. If you want to read the @style attribute of the <ul/> tag, you have to use two step expressions: stepping into the list, then into the attribute. Each must be seperated using a /, the @ only denominates an attribute.

//ul/@style
Sign up to request clarification or add additional context in comments.

3 Comments

"Does not work" is not an error description that helps. Read the FAQ and about how to post an SSCCE.
Sorry about that. I tried this but have the same issue: string(1) ";"
This still does not provide a sufficient error description (also the question posted above doesn't). Nobody will be able to help you as it is, without being able to reproduce the issue and/or knowing the input.

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.