简体   繁体   English

从Atom XML删除所有XML属性

[英]Remove all XML Attributes from Atom XML

We are trying to remove all the attributes from our XML. 我们正在尝试从XML中删除所有属性。 The parser we use can't handle the attributes that are mentioned in the XML. 我们使用的解析器无法处理XML中提到的属性。

We don't think it is possible in one regex so we are looking for alternatives. 我们认为不可能在一个正则表达式中实现,因此我们正在寻找替代方法。 We think that the best approach is maybe to create a regex for each tag. 我们认为最好的方法可能是为每个标签创建一个正则表达式。

Example 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>

Well... maybe this could help to you. 好吧...也许这可能对您有所帮助。

\<[a-zA-Z0-9\s\=\":\.]+\>(.*)<\/[a-zA-Z\:]+>

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM