[erlang-questions] Re: Compare XML string

Sand T sand.softnet1@REDACTED
Wed Jun 30 06:11:33 CEST 2010


Hi,

Thanks a lot for the team suggestion, I use erlsom with XSD and it
works well. The tree generated for following XML are identical

<item attr1="value1" attr2="value2"/>
and
<item attr2="value2" attr1="value1 />

and are different for

<item attr1="value1" attr2="value2"/>
and
<item attr2="value20" attr1="value10 />

This makes the comparison easy. Also, the XSD enables xml validation
and hence the XML string can be verified for any missing/additional
attributes in XML.

I knew XSD can be used for XML validation in Java, but had no idea if
erlang has support for XSD. Thanks to Willem Jong for pointing this
out. However, xmerl still dont have support for XSD and hence using
erlsom makes better sense.

Once again, thanks for the team effort.

Regards,
Sandeep




On Wed, Jun 30, 2010 at 9:25 AM, Michael McDaniel <erlangy@REDACTED> wrote:
> On Wed, Jun 30, 2010 at 09:17:36AM +0530, Sand T wrote:
>> Yes, both are identical. I need to compare xml strings/documents
>>
>> ~Sand
>>
>> On Tue, Jun 29, 2010 at 5:10 PM, Dmitry Belyaev <rumata-estor@REDACTED> wrote:
>> > First of all, what does author want to compare: plain strings or xml
>> > documents?
>> >
>> > If documents (or parts of documents) then what about order of attributes and
>> > child elements? Does it matter?
>> >
>> > <item attr1="value1" attr2="value2"/>
>> > <item attr2="value2" attr1="value1></item>
>> >
>> > Sand, do you count them identical?
>> >
>> > Dmitry Belyaev
>> >
>> >
>> > On 06/29/2010 03:32 PM, Steve Davis wrote:
>> >>
>> >> Am I under-thinking this if I say:
>> >>
>> >> case GivenString of
>> >> ExpectedString ->  ok;
>> >> _ ->  error
>> >> end.
>> >>
>> >> ..or is the question really as simple as it sounds.
>> >>
>> >> /s
>> >>
>> >> On Jun 25, 1:43 am, Sand T<sand.softn...@REDACTED>  wrote:
>> >>
>> >>>
>> >>> Hi,
>> >>>
>> >>> I need to compare two given XML string to ensure that the two strings
>> >>> are identical or not at runtime. Does anyone have any idea on how to
>> >>> do this in erlang?
>> >>>
>> >>> Following are some of the examples
>> >>> Given String
>> >>> <response type=\"progress\" im=\"IM\" login=\"ABC\"
>> >>> code=\"102\">Authentication Successful ...</response>
>> >>> Exp String:
>> >>> <response type=\"progress\" im=\"IM\" login=\"ABC\"
>> >>> code=\"102\">Authentication Successful ...</response>
>> >>>
>> >>> Eq 2:
>> >>> Given String
>> >>> <response type=\"progress\" im=\"IM\" login=\"ABC\"
>> >>> code=\"102\">Authentication Successful ...</response>
>> >>> <buddies im=\"IM\" login=\"ABC\"><buddy name=\"XYZ\" nickname=\"\"
>> >>> status=\"offline\" custom=\"Is offline\" group=\"Friends\"
>> >>> blocked=\"no\"/></buddies>
>> >>>
>> >>> Expected:
>> >>> <response type=\"progress\" im=\"IM\" login=\"ABC\">Authentication
>> >>> Successful ...</response>
>> >>> <buddies im=\"IM\" login=\"ABC\"><buddy name=\"XYZ\" nickname=\"\"
>> >>> status=\"online\" custom=\"Is offline\" group=\"Friends\"
>> >>> blocked=\"no\"/></buddies>
>> >>>
>> >>> Regards,
>> >>> Sandeep
>> >>>
> ________________________________________________________________
>
>
>  truly *identical* ?
>  as in "a" = "a" is identical and "a" = "a " is not identical ?
>
>
>  if so,
>
>
>   try XML_one = XML_two of
>      XML_one       -> true
>      catch _:_     -> false
>   end
>
>
> ~Michael
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>


More information about the erlang-questions mailing list