从Atom XML中删除所有XML属性

时间:2015-11-17 11:03:51

标签: regex xml regex-negation regex-lookarounds atom-feed

我们正在尝试从XML中删除所有属性。我们使用的解析器无法处理XML中提到的属性。

我们认为在一个正则表达式中是可能的,所以我们正在寻找替代方案。 我们认为最好的方法可能是为每个标签创建一个正则表达式。

示例XML:

<?xml version='1.0' encoding='utf-8'?>
<feed xml:base="https://hcm12preview.sapsf.eu/odata/v2/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
    <title type="text">Todo</title>
    <id>https://hcm12preview.sapsf.eu/odata/v2/Todo</id>
    <updated>2015-11-17T10:30:34Z</updated>
    <link href="Todo" rel="self" title="Todo"/>
    <entry>
        <id>https://hcm12preview.sapsf.eu/odata/v2/Todo('5')</id>
        <title type="text"/>
        <updated>2015-11-17T10:30:34Z</updated>
        <author>
            <name/>
        </author>
        <link href="Todo('5')" rel="edit" title="Todo"/>
        <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="SFOData.Todo"/>
        <content type="application/xml">
            <m:properties>
                <d:categoryId>5</d:categoryId>
                <d:todos m:type="Bag(SFOData.ToDoBean)">
                    <d:element>
                        <d:categoryId>5</d:categoryId>
                        <d:completedDate m:null="true"/>
                        <d:dueDate m:null="true"/>
                        <d:dueDateOffSet m:type="Edm.Int32">-2147483648</d:dueDateOffSet>
                        <d:entries m:type="Bag(SFOData.ToDoEntry)">
                            <d:element>
                                <d:completedDate m:null="true"/>
                                <d:formDataId m:type="Edm.Int64">15301</d:formDataId>
                                <d:status m:type="Edm.Int32">2</d:status>
                                <d:statusLabel>Actief</d:statusLabel>
                                <d:subjectFullName>Recruitment Request :1508 - Receptionist</d:subjectFullName>
                                <d:subjectId m:null="true"/>
                                <d:url>https://www.example.com</d:url>
                            </d:element>
                        </d:entries>
                        <d:entryId m:type="Edm.Int32">10884</d:entryId>
                        <d:name>Ontwerp aanvraag</d:name>
                        <d:status m:type="Edm.Int32">2</d:status>
                        <d:statusLabel>Actief</d:statusLabel>
                        <d:stepDescAlt>Ontwerp aanvraag</d:stepDescAlt>
                        <d:todoItemId m:null="true"/>
                        <d:url>https://www.example.com</d:url>
                    </d:element>
                    <d:element>
                        <d:categoryId>5</d:categoryId>
                        <d:completedDate m:null="true"/>
                        <d:dueDate m:null="true"/>
                        <d:dueDateOffSet m:type="Edm.Int32">-2147483648</d:dueDateOffSet>
                        <d:entries m:type="Bag(SFOData.ToDoEntry)">
                            <d:element>
                                <d:completedDate m:null="true"/>
                                <d:formDataId m:type="Edm.Int64">15304</d:formDataId>
                                <d:status m:type="Edm.Int32">2</d:status>
                                <d:statusLabel>Actief</d:statusLabel>
                                <d:subjectFullName>Recruitment Request : 9002 - Facility &amp; Fleet Coordinator</d:subjectFullName>
                                <d:subjectId m:null="true"/>
                                <d:url>https://www.example.com</d:url>
                            </d:element>
                            <d:element>
                                <d:completedDate m:null="true"/>
                                <d:formDataId m:type="Edm.Int64">15302</d:formDataId>
                                <d:status m:type="Edm.Int32">1</d:status>
                                <d:statusLabel>ophanden</d:statusLabel>
                                <d:subjectFullName>Recruitment Request : 2001 - Chief Business Innovation Officer</d:subjectFullName>
                                <d:subjectId m:null="true"/>
                                <d:url>https://www.example.com</d:url>
                            </d:element>
                            <d:element>
                                <d:completedDate m:null="true"/>
                                <d:formDataId m:type="Edm.Int64">15303</d:formDataId>
                                <d:status m:type="Edm.Int32">1</d:status>
                                <d:statusLabel>ophanden</d:statusLabel>
                                <d:subjectFullName>Recruitment Request : 2001 - Chief Business Innovation Officer</d:subjectFullName>
                                <d:subjectId m:null="true"/>
                                <d:url>https://www.example.com</d:url>
                            </d:element>
                        </d:entries>
                        <d:entryId m:type="Edm.Int32">10905</d:entryId>
                        <d:name>Aanvraag bij Board</d:name>
                        <d:status m:type="Edm.Int32">2</d:status>
                        <d:statusLabel>Actief</d:statusLabel>
                        <d:stepDescAlt>Aanvraag bij Board</d:stepDescAlt>
                        <d:todoItemId m:null="true"/>
                        <d:url>https://www.example.com</d:url>
                    </d:element>
                </d:todos>
                <d:categoryLabel>Nieuw talent rekruteren</d:categoryLabel>
                <d:displayOrder m:type="Edm.Int32">5</d:displayOrder>
            </m:properties>
        </content>
    </entry>
    <entry>
        <id>https://hcm12preview.sapsf.eu/odata/v2/Todo('11')</id>
        <title type="text"/>
        <updated>2015-11-17T10:30:34Z</updated>
        <author>
            <name/>
        </author>
        <link href="Todo('11')" rel="edit" title="Todo"/>
        <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="SFOData.Todo"/>
        <content type="application/xml">
            <m:properties>
                <d:categoryId>11</d:categoryId>
                <d:todos m:type="Bag(SFOData.ToDoBean)">
                    <d:element>
                        <d:categoryId>11</d:categoryId>
                        <d:completedDate m:null="true"/>
                        <d:dueDate m:type="Edm.DateTime">2015-08-28T00:00:00</d:dueDate>
                        <d:dueDateOffSet m:type="Edm.Int32">81</d:dueDateOffSet>
                        <d:entries m:type="Bag(SFOData.ToDoEntry)">
                            <d:element>
                                <d:completedDate m:null="true"/>
                                <d:formDataId m:type="Edm.Int64">14352</d:formDataId>
                                <d:status m:type="Edm.Int32">2</d:status>
                                <d:statusLabel>Actief</d:statusLabel>
                                <d:subjectFullName>Test Tester for 8050 - Technieker int Version - 3</d:subjectFullName>
                                <d:subjectId m:null="true"/>
                                <d:url>https://hcm12preview.sapsf.eu/sf/recruiting/jobreqsummary/offerapprovals?company=DummyCompany</d:url>
                            </d:element>
                            <d:element>
                                <d:completedDate m:null="true"/>
                                <d:formDataId m:type="Edm.Int64">14101</d:formDataId>
                                <d:status m:type="Edm.Int32">2</d:status>
                                <d:statusLabel>Actief</d:statusLabel>
                                <d:subjectFullName>Guy Londers for 8050 - Technieker int Version - 1</d:subjectFullName>
                                <d:subjectId m:null="true"/>
                                <d:url>https://hcm12preview.sapsf.eu/sf/recruiting/jobreqsummary/offerapprovals?company=DummyCompany</d:url>
                            </d:element>
                            <d:element>
                                <d:completedDate m:null="true"/>
                                <d:formDataId m:type="Edm.Int64">14251</d:formDataId>
                                <d:status m:type="Edm.Int32">2</d:status>
                                <d:statusLabel>Actief</d:statusLabel>
                                <d:subjectFullName>svea huygelen for 8050 - Technieker int Version - 1</d:subjectFullName>
                                <d:subjectId m:null="true"/>
                                <d:url>https://hcm12preview.sapsf.eu/sf/recruiting/jobreqsummary/offerapprovals?company=DummyCompany</d:url>
                            </d:element>
                        </d:entries>
                        <d:entryId m:type="Edm.Int32">10004</d:entryId>
                        <d:name>Goedkeuringen aanbiedingen in behandeling</d:name>
                        <d:status m:type="Edm.Int32">2</d:status>
                        <d:statusLabel>Actief</d:statusLabel>
                        <d:stepDescAlt>Goedkeuringen aanbiedingen in behandeling</d:stepDescAlt>
                        <d:todoItemId m:null="true"/>
                        <d:url>https://hcm12preview.sapsf.eu/sf/recruiting/jobreqsummary/offerapprovals?company=DummyCompany</d:url>
                    </d:element>
                    <d:element>
                        <d:categoryId>11</d:categoryId>
                        <d:completedDate m:null="true"/>
                        <d:dueDate m:type="Edm.DateTime">2015-10-04T00:00:00</d:dueDate>
                        <d:dueDateOffSet m:type="Edm.Int32">44</d:dueDateOffSet>
                        <d:entries m:type="Bag(SFOData.ToDoEntry)">
                            <d:element>
                                <d:completedDate m:null="true"/>
                                <d:formDataId m:type="Edm.Int64">14552</d:formDataId>
                                <d:status m:type="Edm.Int32">2</d:status>
                                <d:statusLabel>Actief</d:statusLabel>
                                <d:subjectFullName>Tom Verplancken voor 8050 - Technieker int Versie - 2</d:subjectFullName>
                                <d:subjectId m:null="true"/>
                                <d:url>https://hcm12preview.sapsf.eu/sf/recruiting/jobreqsummary/offerapprovals?company=DummyCompany</d:url>
                            </d:element>
                            <d:element>
                                <d:completedDate m:null="true"/>
                                <d:formDataId m:type="Edm.Int64">14551</d:formDataId>
                                <d:status m:type="Edm.Int32">2</d:status>
                                <d:statusLabel>Actief</d:statusLabel>
                                <d:subjectFullName>Nadine Martens voor 8050 - Technieker int Versie - 2</d:subjectFullName>
                                <d:subjectId m:null="true"/>
                                <d:url>https://hcm12preview.sapsf.eu/sf/recruiting/jobreqsummary/offerapprovals?company=DummyCompany</d:url>
                            </d:element>
                        </d:entries>
                        <d:entryId m:type="Edm.Int32">10224</d:entryId>
                        <d:name>Goedkeuringen aanbiedingen in behandeling</d:name>
                        <d:status m:type="Edm.Int32">2</d:status>
                        <d:statusLabel>Actief</d:statusLabel>
                        <d:stepDescAlt>Goedkeuringen aanbiedingen in behandeling</d:stepDescAlt>
                        <d:todoItemId m:null="true"/>
                        <d:url>https://hcm12preview.sapsf.eu/sf/recruiting/jobreqsummary/offerapprovals?company=DummyCompany</d:url>
                    </d:element>
                    <d:element>
                        <d:categoryId>11</d:categoryId>
                        <d:completedDate m:null="true"/>
                        <d:dueDate m:type="Edm.DateTime">2015-10-15T00:00:00</d:dueDate>
                        <d:dueDateOffSet m:type="Edm.Int32">33</d:dueDateOffSet>
                        <d:entries m:type="Bag(SFOData.ToDoEntry)">
                            <d:element>
                                <d:completedDate m:null="true"/>
                                <d:formDataId m:type="Edm.Int64">14852</d:formDataId>
                                <d:status m:type="Edm.Int32">2</d:status>
                                <d:statusLabel>Actief</d:statusLabel>
                                <d:subjectFullName>Brenda Peters for 9007 - Technical Facility Teamleader Version - 3</d:subjectFullName>
                                <d:subjectId m:null="true"/>
                                <d:url>https://hcm12preview.sapsf.eu/sf/recruiting/jobreqsummary/offerapprovals?company=DummyCompany</d:url>
                            </d:element>
                        </d:entries>
                        <d:entryId m:type="Edm.Int32">10369</d:entryId>
                        <d:name>Goedkeuringen aanbiedingen in behandeling</d:name>
                        <d:status m:type="Edm.Int32">2</d:status>
                        <d:statusLabel>Actief</d:statusLabel>
                        <d:stepDescAlt>Goedkeuringen aanbiedingen in behandeling</d:stepDescAlt>
                        <d:todoItemId m:null="true"/>
                        <d:url>https://hcm12preview.sapsf.eu/sf/recruiting/jobreqsummary/offerapprovals?company=DummyCompany</d:url>
                    </d:element>
                </d:todos>
                <d:categoryLabel>Goedkeuring van aanbieding</d:categoryLabel>
                <d:displayOrder m:type="Edm.Int32">11</d:displayOrder>
            </m:properties>
        </content>
    </entry>
</feed>

1 个答案:

答案 0 :(得分:0)

嗯......也许这对你有帮助。

{{1}}

https://regex101.com/r/jL3bT7/1