on 2024 Jul 09 9:41 AM
hi,
I need to read the value of an attribute of a payload in xml via a content modifier
I found this blog, but I don't know what to put in place of 'value' since in my case the attribute does not take on a fixed value, but can have different values
this is an example of my xml
<ns0:test>
<tes2 ns1:testattribute="test">
</tes2>
</ns0:test>
i need to read the attribute ns1:testattribute
thank you
Request clarification before answering.
Dear Mark_Fryu,
To read the value of an attribute from an XML file, you can use an XPath query. Since the attribute doesn't have a fixed value, you'll use a general query
to extract the attribute instead of a specific value.
Let's assume you've created a WebDriver object and are on the page containing the XML document, or have already loaded it.
Reading the attribute might then look like this in Java code (Java is used as an example here, and depending on your preferred language, you can of
course use a different language)
…
// Create the object
WebDriver myDriver = new ChromeDriver();
// Load the XML-File
myDriver.get("Filepath");
// Read the attribute
String attributeVal = myDriver.findElement(By.xpath("//tes2")).getAttribute("ns1:testattribute");
...
Best regards
Dennis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
15 | |
12 | |
7 | |
7 | |
4 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.