Skip to main content
edited body
Source Link
pss
  • 21
  • 4

For getting the attribute value from the below mentioned xml for attribute code from tag c

Randomrandom.xml

<a>
    <b>
        <c id="123" code="abc" date="12-12-2022"/>
        <c id="123" code="efg" date="12-12-2022"/>
        <c id="123" date="12-12-2022"/>
    </b>
</a>

Currently the logic is:

cat random.xml | egrep "<c.*/>" | awk -F1 ' /code=/ {f=NR} f&&NR-1==f' RS='"'

How does the above logic work to get the values of code from tag c?

Getting the expected output:

abc
efg

For getting the attribute value from the below mentioned xml for attribute code from tag c

Random.xml

<a>
    <b>
        <c id="123" code="abc" date="12-12-2022"/>
        <c id="123" code="efg" date="12-12-2022"/>
        <c id="123" date="12-12-2022"/>
    </b>
</a>

Currently the logic is:

cat random.xml | egrep "<c.*/>" | awk -F1 ' /code=/ {f=NR} f&&NR-1==f' RS='"'

How does the above logic work to get the values of code from tag c?

Getting the expected output:

abc
efg

For getting the attribute value from the below mentioned xml for attribute code from tag c

random.xml

<a>
    <b>
        <c id="123" code="abc" date="12-12-2022"/>
        <c id="123" code="efg" date="12-12-2022"/>
        <c id="123" date="12-12-2022"/>
    </b>
</a>

Currently the logic is:

cat random.xml | egrep "<c.*/>" | awk -F1 ' /code=/ {f=NR} f&&NR-1==f' RS='"'

How does the above logic work to get the values of code from tag c?

Getting the expected output:

abc
efg
added 14 characters in body
Source Link
pss
  • 21
  • 4

For getting the attribute value from the below mentioned xml for attribute code from tag c

Random.xml

<a>
    <b>
        <c id="123" code="abc" date="12-12-2022"/>
        <c id="123" code="efg" date="12-12-2022"/>
        <c id="123" date="12-12-2022"/>
    </b>
</a>

Currently the logic is:

cat random.xml | egrep "<c.*/>" | awk -F1 ' /code=/ {f=NR} f&&NR-1==f' RS='"'

How does the above logic work to get the values of code from tag c?

Getting the expected output:

abc
efg

For getting the attribute value from the below mentioned xml for attribute code from tag c

<a>
    <b>
        <c id="123" code="abc" date="12-12-2022"/>
        <c id="123" code="efg" date="12-12-2022"/>
        <c id="123" date="12-12-2022"/>
    </b>
</a>

Currently the logic is:

cat random.xml | egrep "<c.*/>" | awk -F1 ' /code=/ {f=NR} f&&NR-1==f' RS='"'

How does the above logic work to get the values of code from tag c?

Getting the expected output:

abc
efg

For getting the attribute value from the below mentioned xml for attribute code from tag c

Random.xml

<a>
    <b>
        <c id="123" code="abc" date="12-12-2022"/>
        <c id="123" code="efg" date="12-12-2022"/>
        <c id="123" date="12-12-2022"/>
    </b>
</a>

Currently the logic is:

cat random.xml | egrep "<c.*/>" | awk -F1 ' /code=/ {f=NR} f&&NR-1==f' RS='"'

How does the above logic work to get the values of code from tag c?

Getting the expected output:

abc
efg
added 27 characters in body
Source Link
pss
  • 21
  • 4

For getting the attribute value from the below mentioned xml for attribute code from tag c

<a>
    <b>
        <c id="123" code="abc" date="12-12-2022"/>
        <c id="123" code="efg" date="12-12-2022"/>
        <c id="123" date="12-12-2022"/>
    </b>
</a>

Currently the logic is:

cat random.xml | egrep "<c.*/>" | awk -F1 ' /code=/ {f=NR} f&&NR-1==f' RS='"'

How does the above logic work to get the values of code from tag c?

Getting the expected output:

abc
efg

For getting the attribute value from the below mentioned xml for attribute code from tag c

<a>
    <b>
        <c id="123" code="abc" date="12-12-2022"/>
        <c id="123" code="efg" date="12-12-2022"/>
        <c id="123" date="12-12-2022"/>
    </b>
</a>

Currently the logic is:

cat random.xml | egrep "<c.*/>" | awk -F1 ' /code=/ {f=NR} f&&NR-1==f' RS='"'

How does the above logic work to get the values?

Getting the expected output:

abc
efg

For getting the attribute value from the below mentioned xml for attribute code from tag c

<a>
    <b>
        <c id="123" code="abc" date="12-12-2022"/>
        <c id="123" code="efg" date="12-12-2022"/>
        <c id="123" date="12-12-2022"/>
    </b>
</a>

Currently the logic is:

cat random.xml | egrep "<c.*/>" | awk -F1 ' /code=/ {f=NR} f&&NR-1==f' RS='"'

How does the above logic work to get the values of code from tag c?

Getting the expected output:

abc
efg
added 12 characters in body
Source Link
pss
  • 21
  • 4
Loading
deleted 31 characters in body
Source Link
pss
  • 21
  • 4
Loading
edited tags
Link
Wiktor Stribiżew
  • 630.7k
  • 41
  • 501
  • 629
Loading
Source Link
pss
  • 21
  • 4
Loading