1 year ago

#302783

test-img

Miss.Pepper

Get networkx graph from xml file (xmlns)

I want a networkx graph from a xml file (xmlns).

I understand that the namespaces are the issue, but reading several questions, trying out different parsers and answers aren’t getting me there. (Engineer wanting to solve stuff by googling, not a capable coder)

XML content

Here follows modified xml file content.

Note Many instances of the same type are removed, but all unique type of instances are present. Ie. it won’t make sense to parse this data, as too much is missing/ altered to give any relationships.

<?xml version="1.0" encoding="utf-8"?>
<PrE xmlns:dat="Example-Z 098-dat-11#">    
    <Segment>
        <mRID>021b10cc-bbd1-6789-9aac-4606dec13bac</mRID>
        <Type ref="f84b0acc-6789-5ccc-bf88-01bad39b3c5b"/>
        <BaVe ref="8c07516d-6789-59d2-b72f-ebc73fc4d06f"/>
        <le multiplier="none" unit="m">64.536756123411005</le>
        <r7bv multiplier="none" unit="R"></r7bv>
        <gbv multiplier="none" unit="L"></gbv>
        <a multiplier="none" unit="red">0.034</a>
        <a0 multiplier="none" unit="red">0.034</a0>
        <b multiplier="none" unit="red">0.008987762298886673</b>
        <b0 multiplier="none" unit="red">1.1234702988684403E-05</b0>
    </Segment>
    <BaVe>
        <mRID>8c07516d-6789-59d2-b72f-ebc73fc4d06f</mRID>
        <nomVa multiplier="none" unit="V">230</nomVa>
    </BaVe>
    <BaVe>
        <mRID>fe55884e-6789-57f6-b284-2601144b69cc</mRID>
        <nomVa multiplier="none" unit="W">3</nomVa>
    </BaVe>
    <BSect>
        <mRID>0d4e1b71-6789-517e-852f-f444c8a4a85c</mRID>
        <name>RG123456-BSect</name>
    </BSect>
    <BSect>
        <mRID>d1378e42-445f-5db1-b777-4de56d7a9c8b</mRID>
        <name>NV9498 - t 1-BSect</name>
    </BSect>
    <ConN>
        <mRID>2988efc1-76b1-6789-98d6-12f9bded6863</mRID>
    </ConN>
    <EC>
        <mRID>034ecb27-9689-6789-9de2-70bcf52e69d2</mRID>
        <BaVe ref="8c07516d-2004-59d2-b72f-ebc73fc4d06f"/>
    </EC>
    <ExtNIExt>
        <mRID>4303272d-ae0b-5b2b-bb24-6789c6b9b658</mRID>
        <maxA multiplier="none" unit="A">1871.59</maxA>
        <minA multiplier="none" unit="A">1239.93</minA>
        <vF>1</vF>
        <cP>0.11</cP>
        <BaVe ref="fe55884e-7669-57f6-b284-2601144b69cc"/>
    </ExtNIExt>
    <PT>
        <mRID>e16f22ef-6789-5c9b-a6df-63fe2b21c56a</mRID>
        <name>1002988</name>
        <ECont ref="a1ac4bd1-be54-5e65-9de4-4d2988d3b796"/>
    </PT>
    <PTEE>
        <mRID>12ef14df-4c9c-5c30-ab39-6789ff57f71a</mRID>
        <eMo>2</eMo>
        <rA multiplier="none" unit="G">123</rA>
        <rS multiplier="none" unit="GA">100</rS>
        <r0>0</r0>
        <x0>0</x0>
        <Lk>3.2988999713897696</Lk>
        <Lr>1.2988999999999999</Lr>
        <PT ref="e16f22ef-1593-5c9b-a6df-63fe2b21c56a"/>
        <Term ref="a5142186-d1e6-5940-b161-92ee5d6e5fd5"/>
        <BaVe ref="8c07516d-2004-59d2-b72f-ebc73fc4d06f"/>
    </PTEE>
    <Type>
        <mRID>8e8072d6-599d-593e-6789-e4c432cf2c4d</mRID>
        <name>Cap</name>
    </Type>
    <Type>
        <mRID>b59fefe6-3eda-6789-958f-4678140c6db8</mRID>
        <name>SecS</name>
    </Type>
    <Type>
        <mRID>c31ef7d7-9d5f-5e09-9e1f-5d5d8406c0b8</mRID>
        <name>Unk</name>
    </Type>
    <Type>
        <mRID>f84b0acc-6357-5ccc-bf99-01bad39b3c5b</mRID>
        <name>OLi</name>
    </Type>
    <RTC>
        <mRID>92bea3ad-5ec7-562b-b7e8-3a54f825558d</mRID>
        <stepVI>2.5</stepVI>
        <TEd ref="12ef14df-4c9c-5c30-ab39-7423ff57f71a"/>
    </RTC>
    <Sub>
        <mRID>a1ac4bd1-be54-5e65-9de4-4d6789d3b796</mRID>
        <name>NL1234</name>
        <description>Rid 42</description>
        <Type ref="b59fefe6-3eda-5465-958f-4678140c6db8"/>
    </Sub>
    <Term>
        <mRID>0036a224-cdbe-6789-955b-f662ea2432d8</mRID>
        <seqNo>2</seqNo>
        <ConN ref="cfb319a5-e9be-5d31-ac31-5186e9fa5b26"/>
        <CondE ref="70fc91e6-9ce4-5e42-a813-8c39407a3c92"/>
    </Term>
    <UPExt>
        <mRID>0b8e056c-1eab-9d4c-a6f2-e2d3bc56ae56</mRID>
        <measID>678967896789678995</measID>
        <Eq ref="cc3d36bb-9329-6789-b8d2-53c0b99f9504"/>
    </UPExt>
    <LBS>
        <mRID>2d9deef5-603e-5387-8d06-8744a75b6aa6</mRID>
        <name>1</name>
        <noO>false</noO>
    </LBS>
    <Brak>
        <mRID>8903a50b-c841-6789-bb6d-066198cece5d</mRID>
        <name>CV98743.1</name>
        <noO>false</noO>
    </Brak>
    <Funv>
        <mRID>ad7dd46d-3c81-6789-aac3-cb01f083a897</mRID>
        <name>3</name>
        <noO>false</noO>
    </Funv>
</PrE>

python-3.x

xml

networkx

xml-namespaces

0 Answers

Your Answer

Accepted video resources