Question XML Element in BizTalk help needed

bpleshek

New member
Joined
Sep 14, 2010
Messages
1
Programming Experience
10+
I am doing an EDI app in BizTalk. I am not proficient in XSLT, so I'm attempting to use VB.NET to create what I need. I have an XML format that I am translating data into in this format:

<L11>
<L1101/>
<L1102/>
</L11>

I have figured out that it will take an xmlElement object data type. I have the following code:

dim x as xml.xmlelement
dim y as xml.xmlelement
doc as new system.xml.xmldocument

x= doc.createelement("L11")

'Loop that builds a string that's not relevant this part works.

y=doc.CreateElement("L1101", "L1101")
y.innertext = sFirst 'One of the built strings.
x.appendchild(y)

y=doc.CreateElement("L1102", "L1102")
y.innertext = sLast 'One of the built strings.
x.appendchild(y)

sFirst=""
sLast=""
'End Loop

Oh and at the end the function returns X

My problem is that when I direct the output of this to my XML document, I get this:

<L11>18553818TN10072709SI1452354CN</L11>

Instead of:

<L11>
<L1101>18553818</L1101>
<L1102>TN</L1102>
<L1101>10072709</L1101>
<L1102>SI</L1102>
<L1101>1452354</L1101>
<L1102>CN</L1102>
</L11>

Am I missing some property or something that I need to set in the XML element object?

Thanks,

Brian
 
My problem is that when I direct the output of this to my XML document, I get this:
You 'direct' the output how? According to posted code the OuterXml of the 'x' XmlElement is this (indented), so if the namespaces is supposed to be there that appears to be correct:
HTML:
<L11>
  <L1101 xmlns="L1101">sFirst</L1101>
  <L1102 xmlns="L1102">sLast</L1102>
</L11>
<L11>18553818TN10072709SI1452354CN</L11>
The string inside L11 node here corresponds to InnerText of that node (given the node texts you posted), perhaps it has something to do with your direction or other view related issue, but it is not what the code produces.

Btw, I agree with JB a XmlTextWriter is usually easier to use when producing a complete new Xml document.
 
Back
Top