RemoveNodesFromXML

Stable Version 1.0.1 (Compatible with OutSystems 11)
Published on 29 Jan by 
0.0
 (0 ratings)

RemoveNodesFromXML

Details
It allows you to remove nodes with a given name from an XML file
Read More

It allows you to remove nodes with a given name from an XML file. Please see printscreen attached for the method schema.


Given a XML like this where there's xsd info as well as actual data, the XML to record list extension throws errors. This extension was developed as a workarround for this issue but it can be used to remove any XML node by it's name.

For my particular usecase, to remove the "xsd:schema" node from the XML i just need to invoke the extension method passing "xds:schema" in the NodeName input parameter and it removes the full node and outputs an XML which is already parsable by the XML to record list extension.


<Users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <xsd:schema targetNamespace="urn:schemas-microsoft-com:sql:SqlRowSet1" xmlns:schema="urn:schemas-microsoft-com:sql:SqlRowSet1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sqltypes="http://schemas.microsoft.com/sqlserver/2004/sqltypes" elementFormDefault="qualified">
    <xsd:import namespace="http://schemas.microsoft.com/sqlserver/2004/sqltypes" schemaLocation="http://schemas.microsoft.com/sqlserver/2004/sqltypes/sqltypes.xsd" />
    <xsd:element name="h1_users">
      <xsd:complexType>
        <xsd:sequence>
          <xsd:element name="ID" type="sqltypes:uniqueidentifier" nillable="1" />
          <xsd:element name="userId" type="sqltypes:int" nillable="1" />
          <xsd:element name="locale" nillable="1">
            <xsd:simpleType>
              <xsd:restriction base="sqltypes:varchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">
                <xsd:maxLength value="10" />
              </xsd:restriction>
            </xsd:simpleType>
          </xsd:element>
          <xsd:element name="prefix" nillable="1">
            <xsd:simpleType>
              <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">
                <xsd:maxLength value="40" />
              </xsd:restriction>
            </xsd:simpleType>
          </xsd:element>
          <xsd:element name="firstName" nillable="1">
            <xsd:simpleType>
              <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">
                <xsd:maxLength value="80" />
              </xsd:restriction>
            </xsd:simpleType>
          </xsd:element>
          <xsd:element name="Infix" nillable="1">
            <xsd:simpleType>
              <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">
                <xsd:maxLength value="80" />
              </xsd:restriction>
            </xsd:simpleType>
          </xsd:element>
          <xsd:element name="lastName" nillable="1">
            <xsd:simpleType>
              <xsd:restriction base="sqltypes:nvarchar" sqltypes:localeId="1033" sqltypes:sqlCompareOptions="IgnoreCase IgnoreKanaType IgnoreWidth" sqltypes:sqlSortId="52">
                <xsd:maxLength value="80" />
              </xsd:restriction>
            </xsd:simpleType>
          </xsd:element>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
  <h1_users xmlns="urn:schemas-microsoft-com:sql:SqlRowSet1">
    <ID>F36D1B2D-5450-4A6D-9738-B33505576537</ID>
    <userId>100006</userId>
    <locale>en</locale>
    <prefix>Prof. Dr.</prefix>
    <firstName>Marion</firstName>
    <Infix xsi:nil="true" />
    <lastName>Bernhardt</lastName>
  </h1_users>
  <h1_users xmlns="urn:schemas-microsoft-com:sql:SqlRowSet1">
    <ID>9AC0DC4C-071C-4E63-8887-F61EF7F93FAC</ID>
    <userId>100050</userId>
    <locale>en</locale>
    <prefix>Dr.</prefix>
    <firstName>Jens</firstName>
    <Infix xsi:nil="true" />
    <lastName>Moraht</lastName>
  </h1_users>
  <h1_users xmlns="urn:schemas-microsoft-com:sql:SqlRowSet1">
    <ID>6BA38691-E626-46DF-A9E0-5B957A3DC5D7</ID>
    <userId>100051</userId>
    <locale>de</locale>
    <prefix>Dr.</prefix>
    <firstName>Joachim</firstName>
    <Infix xsi:nil="true" />
    <lastName>Natterer</lastName>
  </h1_users>
</Users>
What’s new (1.0.1)

input parameter added "AddXMLDeclaration" which will define if "<?xml version="1.0" encoding="utf-8"?>" will present in the beginning of the file or not

Reviews (0)