Desktop version

Main > Forum > 1C:Enterprise Platform > 1C:Enterprise – Business applications platform > How to get to the element value if it has an attribute (XDTO)

Forum

Search UsersRules
How to get to the element value if it has an attribute (XDTO)
#1
Interested
Points:: 15
Joined:: Oct 27, 2011

How to define XDTO package to obtain the value of element if it has an attribute?
Example XML:

Code
<id_lang xlink:href="http://example.com/api/languages/2">
<![CDATA[ 2 ]]>
</id_lang>

When I am trying to convert it to XDTO Object it just show me the value of attribute xlink:href and omits element value no matter how I am trying to describe the XML scheme. In the case of use of AnyType it also show me just attribute value.
The code is:
Code
ExType = XDTOFactory.Type("http://www.sample-package.org", "example");
Object = XDTOFactory.ReadXML(XMLReader, ExType);

"example" defined in configuration

Profile
#2
Interested
Points:: 15
Joined:: Oct 27, 2011

Sorry, forum doesn't permit to post XML. There is just one element, it has a string attribute and the value of element is 2. Nothing more

Profile
#3
Active user
Points:: 1
Joined:: Jul 20, 2011

Try setting the Form property value to Attribute for your package property which should be read from the XML element attribute.

Profile
#4
Interested
Points:: 15
Joined:: Oct 27, 2011

I did that, but it was not enough. I found out that you also have to add another property with the name __content to the type definition but this was not enough too.
It seems to me the problem is with namespaces, because the xml file have an xlink namespace and I use import directive to point out but if I make a xsd-file exporting the XDTO-package it uses other letters (ns1 instead of xlink) to describe a namespace, and I have not found where you could define the representation of namespace for attribute.
I will continue to search around although at this point Id like to kill someone.

Profile
#5
Guest
Points::
Joined::

Please provide XML with data and XML XSD schema (note that you can write and use import for XSD schemas) so we could reproduce your situation.

Profile
#6
Guest
Points::
Joined::

Please, see XML Schema Examples.

Profile
#7
Active user
Points:: 0
Joined:: May 15, 2013

Murat Yazlıyev posted his solution.

Profile
#8
Interested
Points:: 15
Joined:: Oct 27, 2011

It is alive.
Murat's post could be the solution to my initial problem, but I have found that there were no way i could define prefix for namespace so i had to give up.

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.