logo
down
shadow

Return multiple attributes with perl's xpath command


Return multiple attributes with perl's xpath command

By : Waheed Ahmad
Date : November 21 2020, 12:01 PM
will be helpful for those in need (@id|@name) is XPath 2.0 syntax, while Perl xpath uses 1.0. Here's an alternative:
code :
xpath -e '//BaseTable/@*[name()="id" or name() = "name"]' FileName.xml


Share : facebook icon twitter icon
php xpath retrieving attribute-values based on multiple attributes and parent-attributes

php xpath retrieving attribute-values based on multiple attributes and parent-attributes


By : Neuwied Ul Haq
Date : March 29 2020, 07:55 AM
wish helps you Just combine your two XPath query...
Live demo
code :
$str=<<<XML
<scales>
    <scale id="1" gender="*" age="*">
        <d scid="hi" raw="10" t="76" />
        <d scid="pn" raw="12" t="80" />
    </scale>
    <scale id="2" gender="m" age="*">
        <d scid="hi" raw="8" t="79" />
        <d scid="pn" raw="2" t="50" />
    </scale>
    <scale id="3" gender="*" age="19-39">
        <d scid="hi" raw="0" t="48" />
        <d scid="pn" raw="10" t="49" />
    </scale>
</scales>
XML;
$xml=simplexml_load_string($str);
foreach($xml->xpath('//scale[@gender="*" or @gender="m"][@age="*" or @age="39-59"]/d[@scid="hi"][@raw="10"]/@t') as $t)
{
    echo $t;
}
Perls system($command) returns other result than command on shell

Perls system($command) returns other result than command on shell


By : wly65535
Date : March 29 2020, 07:55 AM
To fix this issue You are using double quotes. In double quotes, \ is special, so only + instead of \+ is passed to sed.
You can use the q() operator to avoid backslashing the backslash:
code :
$ssh->cmd(q(head -11 /some/path/to/the/file.xml | tail -1 | sed 's/<[^>]\+>//g' | xargs));
XPath Expression to select specific node and it's attributes having specified multiple attributes

XPath Expression to select specific node and it's attributes having specified multiple attributes


By : Aru mugam
Date : March 29 2020, 07:55 AM
This might help you I don't see a plugins element in your sample input, but assuming that it's there and you just didn't show it, an XPath along these lines should do it:
code :
/plugins/transaction[@code = '501110']/source[@name = 'mmc']/step
Why does perls length function return different results for same input?

Why does perls length function return different results for same input?


By : Axelle D Rouge
Date : March 29 2020, 07:55 AM
Hope that helps These are actually all different strings, all of which contain invisible characters. You can see it if you open the text in a hex editor:
XPath query to match two attributes but return only one

XPath query to match two attributes but return only one


By : user3707308
Date : March 29 2020, 07:55 AM
I hope this helps you . You are nearly there. [] are conditions for the preceding location path. So the expression for the id field values of all defects is:
/Entities/Entity[@Type="defect"]/Fields/Field[@Name="id"]/Value
code :
/Entities/Entity[
  @Type="defect" and (Fields/Field[@Name = "project"]/Value = "Product A")
]/Fields/Field[@Name="id"]/Value
Related Posts Related Posts :
  • Extracting child elements from XML documents w
  • Use a custom xml namespace prefix in type attribute
  • Powershell XmlWriterSettings ident Chars as tabs
  • Parsing an XSLT stylesheet failed in two different namespaces
  • XML schema: How to change the maxLength of all strings in document
  • XML and XSLT - separate node includes commas
  • Why does my xsd validates an undeclared attribute?
  • How do I write the XML back using XML::Parser in perl?
  • Xpath conditional branch
  • Why must XML documents have a single root element?
  • Can root element have text in it?
  • Navigation concept in Roku
  • Removing new line between xml tags in unix shell script
  • How to output <ul> and <li> elements from XML to XSL?
  • SVG tag mismatch
  • xml schema list of incremental element name
  • Overwrite files with XSLT
  • Extract value statement using XML
  • What is the meaning of <xml lang="..">
  • XML Transformation - move childNode to another parentNode if hit maximum occurrence
  • Lateral view / explode in Spark with multiple columns, getting duplicates
  • How to transform xml data using datafactory pipeline
  • Ignore Namespace in XML document using Powershell
  • How can I get data from nested xml which doesn't use end tag in repeat items?
  • Formatter function doesn't work in XML Fragment
  • How to show nested entries within the playlist window in VLC?
  • XPath to get a full node except one child
  • XSLT - Root element not set
  • How to unencode escaped XML with xQuery
  • Find position of a node within a nodeset using xpath
  • Getting XML parse error in ColdFusion. Can the packet returned be validated?
  • Describe repeating XML nodes in W3C XML Schema?
  • Java/XML: Good "Stream-based" Alternative to JAXB?
  • Eclipse complains android:scrollbars and android:fadingEdge do not allow Strings - includes code
  • DTD (or XSD) problem with duplicate name element having different scopes
  • Most efficient way to store list structure in XML
  • What is the correct syntax for XSD to restrict attrributes values in the elements list?
  • Web based XML Editor
  • Looking for a free xsd scheme editor
  • Use XSLT to arrange a list of items in a table
  • XML: Check if anything exists between two nodes
  • Metatool for automatic xml code generation
  • Looking for a library of XSLT to create SVG charts
  • How to decide when to use XSD or DTD?
  • BlackBerry - Extract data from 3rd nesting level of xml
  • XSD schema for recursive XML
  • nokogiri xml unescape
  • How to visualize an XML schema?
  • NSString to NSData Failing in Encoding
  • XmlTextWriter.WriteFullEndElement tags on the same line
  • The case of "id" attribute when signing an element in a XML file
  • Increment a counter in VXML
  • how to build xml schema
  • How define several elements with same name, but different type in xsd:choice element?
  • How can you tell if an XMLlist object in AS3 contains a node?
  • Can XML schema be written to allow xs:attribute of either xs:date or xs:dateTime?
  • how to insert a SAML Assertion to SOAPHeader
  • How to migrate from XslTransform to XslCompiledTransform
  • Is there any better IDOMImplementation other than MSXML?
  • Indesign and XML - how to auto flow into multiple pages with differing styles?
  • shadow
    Privacy Policy - Terms - Contact Us © festivalmusicasacra.org