• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

HELP!

New Here ,
May 19, 2006 May 19, 2006

Copy link to clipboard

Copied

common no one can help out with xml issue? how to insert an element at a specific position?

iam using this ArrayInsertAt(mydoc.employee.name, 2, XmlElemNew(mydoc, "PhoneNumber")
but if the xml doc has only on2 element it alerts me that i cannot insert at position 2! but i need to insert it at the end!

anyone help please!
TOPICS
Advanced techniques

Views

592

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 19, 2006 May 19, 2006

Copy link to clipboard

Copied

If you need to add something to the end of an array, use ArrayAppend.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2006 May 19, 2006

Copy link to clipboard

Copied

Are you looking for a way to add a 3rd element to an XML document that already has 2 elements? Something like this should do it:


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 21, 2006 May 21, 2006

Copy link to clipboard

Copied

Hello BKBK and thx for your reply!

well my problem is how to insert an element between element1 and element2 ..
can you help out with this?

thank you alot for your time.
regards

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
May 21, 2006 May 21, 2006

Copy link to clipboard

Copied

credev this is what you are trying to do:-

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 22, 2006 May 22, 2006

Copy link to clipboard

Copied

worked with this

ArrayInsertAt(xmlDoc.MyDoc.XmlChildren,#position# , XmlElemNew(xmlDoc,"TagTR"));

thnx guys

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 22, 2006 May 22, 2006

Copy link to clipboard

Copied

yes exactly Stressed_Simon it works like that but now iam facing another problem.

when i put values to node like below and later when i do transformation for xmlDoc to HTML
xmlDoc.MyDoc.TagTR[#position#].XmlChildren[2].XmlText = "Palette Hétérogène";

i receive the following Palette Hétérogène its an encoding problem ... how can i solve it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 22, 2006 May 22, 2006

Copy link to clipboard

Copied

An idea

xmlDoc.MyDoc.TagTR[#position#].XmlChildren[2].XmlText = "Palette Hétérogène";

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 23, 2006 May 23, 2006

Copy link to clipboard

Copied

BKBK i tried it but the output was the same

Palette Hétérogène

(

what do you think?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2006 May 23, 2006

Copy link to clipboard

Copied

what do you think?
I think you did not put the output between cfoutput tags or within WriteOutput(). If you do, you will get Palette Hétérogène.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 23, 2006 May 23, 2006

Copy link to clipboard

Copied

LATEST
BKBK this is not it! i already put cfoutput else it would have given me an error.


listen this is my function

<cffunction name="addNewElement" returntype="void">
<cfargument name="position" type="numeric" required="yes">
<cfscript>
ArrayInsertAt(xmlDoc.MyDoc.XmlChildren,#position# , XmlElemNew(xmlDoc,"TagTR"));

StructInsert(xmlDoc.MyDoc.TagTR[#position#].XmlAttributes, "index", "index");

xmlDoc.MyDoc.TagTR[#position#].XmlChildren[1] = XmlElemNew(xmlDoc, "TagTD");
StructInsert(xmlDoc.MyDoc.TagTR[#position#].TagTD[1].XmlAttributes, "libelle", "Emballage");
xmlDoc.MyDoc.TagTR[#position#].XmlChildren[1].XmlText = "Palette Hétérogène";

</cfscript>

</cffunction>


and this is my xsl to transform it to html

<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet
version="2.0"
xmlns:xsl=" http://www.w3.org/1999/XSL/Transform"
xmlns=" http://www.w3.org/TR/REC-html40">

<xsl utput method="html" encoding="utf-8"/>
<xsl:template match="MyDoc">
<xsl:for-each select="TagTR">
<tr class="Arial_2_noir" height="10" align="left" valign="top" bgcolor="#CCCCCC">
<td><xsl:value-of select="TagTD[@libelle='Emballage']" /></td>
</tr>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


so in brief i have an xml Object (cfxml) which i added an element to it then i transform it to HTML and dump it to browser.

anyone can see why i have that problem? my output is "Palette Hétérogène" instead of "Palette Hétérogène"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation