jeudi 2 octobre 2014

compare two xml beautifulsoup


Vote count:

0





"""
<stltxn>
<instrumnetid>1174</instrumnetid>
<version>0</version>
<producttype>OSTK</producttype>
<strike>0.01</strike>
<accountid>422</accountid>
<symbol>ALV</symbol>
<settlamount>500</settlamount>
<clearingbusinessdate>2013_12_18</clearingbusinessdate>
<cptysettlaccount>8501</cptysettlaccount>
<productisin>DE0008404005</productisin>
<productcurrency>EUR</productcurrency>
<settlcurrency>EUR</settlcurrency>
<accrintamount>0</accrintamount>
<settlquantity>500</settlquantity>
<accountsponsor>CBKFR</accountsponsor>
<callput></callput>
<delvsettlprice>1</delvsettlprice>
<accountname>AAA</accountname>
<cashsettlamount>0</cashsettlamount>
<maturity>201312</maturity>
<side>0</side>
<clearinghouse>ECAG</clearinghouse>
<accrintdays>0</accrintdays>
<deliverytype>DELIVERY_AT_SETTLEMENT_AMOUNT</deliverytype>
<productname>OPT ON ALLIANZ AG HOLDIN </productname>
<productsymbol>ALV</productsymbol>
<currency>EUR</currency>
<accountowner>CBKFR</accountowner>
<valuedate>None_12_20</valuedate>
<productid>0</productid>
</stltxn>
"""

"""
<?xml version="1.0" encoding="utf-8"?>
<stlTxn>
<InstrumnetID>1174</InstrumnetID>
<Version>0</Version>
<ProductType>OSTK</ProductType>
<Strike>0.010000</Strike>
<AccountID>422</AccountID>
<Symbol>ALV</Symbol>
<SettlAmount>500.0</SettlAmount>
<ClearingBusinessDate>2013-12-18</ClearingBusinessDate>
<CptySettlAccount>8401</CptySettlAccount>
<ProductISIN>DE0008404005</ProductISIN>
<ProductCurrency>EUR</ProductCurrency>
<SettlCurrency>EUR</SettlCurrency>
<AccrIntAmount>0.0</AccrIntAmount>
<SettlQuantity>500.0</SettlQuantity>
<AccountSponsor>CBKFR</AccountSponsor>
<CallPut>CALL</CallPut>
<DelvSettlPrice>10.0</DelvSettlPrice>
<AccountName>AAA</AccountName>
<CashSettlAmount>100.0</CashSettlAmount>
<Maturity>201312</Maturity>
<Side>BST_BUY</Side>
<ClearingHouse>ECAG</ClearingHouse>
<AccrIntDays>0</AccrIntDays>
<DeliveryType>DELIVERY_AT_SETTLEMENT_AMOUNT</DeliveryType>
<ProductName>OPT ON ALLIANZ AG HOLDIN</ProductName>
<ProductSymbol>ALV</ProductSymbol>
<Currency>EUR</Currency>
<AccountOwner>CBKFR</AccountOwner>
<ValueDate>2013-12-19</ValueDate>
<ProductID>38</ProductID>
</stlTxn>
"""


I want to compare these two fixml messages using beautifulsoup parser, there would be a list of expected and actual messages and for each expected message i want to travere the actual list and find if a similar xml message is present in the actual list:



for attribute in expected.attrs.keys():
if not attribute in actual.attrs:
self._error_message = "Expected attribute '%s' of element %s is not found in actual document" % (attribute,
self.__build_element_path(expected))
return False

if not self.__attribute_is_same(expected[attribute], actual[attribute]):
self._error_message = "Expected attribute '%s' of element %s is different! Expected: '%s' Actual: '%s'" % (attribute,
self.__build_element_path(expected),
expected[attribute], actual[attribute])
return False
return True


I am trying to use above code but it doesnt work as these xml message doesnt have attributes.



asked 18 secs ago







compare two xml beautifulsoup

Aucun commentaire:

Enregistrer un commentaire