This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Knowledge Base
- :
- How to use an xPath to designate an element regardless of Namespace.
Subscribe
- Mark as New
- Mark as Read
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
How to use an xPath to designate an element regardless of Namespace.
How to use an xPath to designate an element regardless of Namespace.
Summary:
An xml being referenced may designate 1 or more Namespaces used. This can be difficult to reference if you are attempting to look for a specific element but are unsure of the Namespace used.
Description:
Using a wild card (*) along with specifying local-name will return a result regardless of namespace.
Example:
This xpath will specify /Project/PropertyGroup/IncludePath from the Sample XML, regardless of the xml namespace given:
/*[local-name()='Project']/*[local-name()='PropertyGroup']/*[local-name()='IncludePath']
Sample XML:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup>
<IncludePath>SampleValue</IncludePath>
</PropertyGroup>
</Project>
<IncludePath>SampleValue</IncludePath>
</PropertyGroup>
</Project>
Additional Info:
It is worth noting, additional xpath syntax may be needed if the elements appear more than once.
Here is some info on namespaces:
No ratings