How to get to the element value if it has an attribute (XDTO)

The 1C:Enterprise developers forum

#1
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

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

 
#2
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

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

 
#3
People who like this:0Yes/0No
Active user
Rating: 3
Joined: Jul 20, 2011
Company:

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

 
#4
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

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.

 
#5
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

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.

 
#6
People who like this:0Yes/0No
Timofey Bugaevsky
Guest

Joined:
Company:

Please, see XML Schema Examples.

 
#7
People who like this:0Yes/0No
Active user
Rating: 2
Joined: May 15, 2013
Company:

Murat Yazlıyev posted his solution.

 
#8
People who like this:0Yes/0No
Interested
Rating: 32
Joined: Oct 27, 2011
Company: Abaco Soluciones S.A.

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.

Edited: Alexey Gerasimov - Mar 08, 2017 07:48 PM
 
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.