Go Premium for a chance to win a PS4. Enter to Win

x

XML

20K

Solutions

13K

Contributors

Extensible Markup Language (XML) refers to the encoding of documents such that they can be read by both machines and humans. XML documents use tags to show the beginning and end of a set of data. XML is used extensively on websites to show volumes of data, and is the default for a number of office productivity suites. This topic includes discussions of XML-related technologies, such as XQuery (the XML Query language), XPath (the XML Path language), XSLT (eXtensible Stylesheet Language Transformations), XLink (the XML Linking language) and XPointer (the XML Pointer language).

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi guys,

Please assist with this validation.
Have an issue to substring from the End of a String.
Please see below

           <xsl:variable name="originalValue" select="'[some Values]'" />

                <xsl:variable name="valueUpdated">
                  <xsl:call-template name="cut-leading-zeros">
                    <xsl:with-param name="str" select="normalize-space($originalValue)" />
                  </xsl:call-template>
                </xsl:variable>


                <!-- If original values does not have leading zeros
                '123'
                '12346578912120112455' 
                '123465789121234567890120222'
                 . . .
                  concat orginal value with prefix 'BX' 
                  -->
                <xsl:if test="$originalValue">
                  <xsl:value-of select="concat('BX', $originalValue)"/>
                </xsl:if>



                <!-- If updated values after removed leading zeros greather then 18
                  '000012346578912120112455' 
                  '0000123465789121234567890' 
                  '00001234657891212345678901' 
                  . . .
                  concat updated value with prefix 'BX' 
                  -->
                <xsl:if test="string-length($valueUpdated) &gt; 18">
                  <xsl:value-of select="concat('BX', $valueUpdated)"/>
                </xsl:if>




                <!-- If original values after removed leading zeros less then 18
           

Open in new window

0
Hire Technology Freelancers with Gigs
LVL 11
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Hi guys,

I am facing an issue with string formatting to remove leading zeros.

when
input = '000111100' or 111100
result is: 111100  - all ok!

when
input = '01111111111111111111101110'
result is: "1111111111111111100000000"
expected result is: 1111111111111111111101110

Function
<xsl:variable name="test1" select="string(number($input))" />

Open in new window

It looks like does not work for large numbers.
Please share if you have an explanation or logic function to remove leading zeros only on any size of value.

Thank You,
Darius
0
I want only the body of this xml
each line on a separate line


  <sms protocol="0" address="5551212" date="1500334066013" type="2" subject="null" body="I ONLY WANT BODY OF MESSAGE" toa="null" sc_toa="null" service_center="null" read="1" status="-1" locked="0" date_sent="0" readable_date="Jul 17, 2017 7:27:46 PM" contact_name="(Unknown)" />
 <sms protocol="0" address="5551212" date="1500334066013" type="2" subject="null" body="I ONLY WANT BODY OF MESSAGE" toa="null" sc_toa="null" service_center="null" read="1" status="-1" locked="0" date_sent="0" readable_date="Jul 17, 2017 7:27:46 PM" contact_name="(Unknown)" />
 <sms protocol="0" address="5551212" date="1500334066013" type="2" subject="null" body="I ONLY WANT BODY OF MESSAGE" toa="null" sc_toa="null" service_center="null" read="1" status="-1" locked="0" date_sent="0" readable_date="Jul 17, 2017 7:27:46 PM" contact_name="(Unknown)" />
 <sms protocol="0" address="5551212" date="1500334066013" type="2" subject="null" body="I ONLY WANT BODY OF MESSAGE" toa="null" sc_toa="null" service_center="null" read="1" status="-1" locked="0" date_sent="0" readable_date="Jul 17, 2017 7:27:46 PM" contact_name="(Unknown)" />
 <sms protocol="0" address="5551212" date="1500334066013" type="2" subject="null" body="I ONLY WANT BODY OF MESSAGE" toa="null" sc_toa="null" service_center="null" read="1" status="-1" locked="0" date_sent="0" readable_date="Jul 17, 2017 7:27:46 PM" contact_name="(Unknown)" />
 <sms protocol="0" 

Open in new window

0
consider following XML -->

<?xml version="1.0" encoding="UTF-8"?>
<abc:Root
    xmlns:abc = "http://www.abc.com"
    xmlns:xyz = "http://www.xyz.com
    xmlns:xlink = "http://www.somelink.com"
    xmlns:xsi = "http://www.somelink.com/schema">

I have a class for the purpose of serialization/deserialization

[XmlRoot(Namespace="http://www.abc.com")]
public partial class Root{

}

How do i deserialize the above XML, so that I don't loose any of the additional namespaces?
with what I have, I ran a test

1. I deserialized the above XML , to create an object.
2. then i serialized the object in step 1, and looked at the XML.
3. The XMl generated is missing other namespace attribute in the root element . It only has the xmlns:abc attribute.

How do I make sure, i don't loose other namespace attribute when I deserialize?
0
Although there is a fair amount of data, I written a fairly basic API which I need to return in XML format. What I need to know is how to send this data back in an XML file. The code below displays a well-formed XML to the browser.
After preliminary processing, a string is sent to the XML processing file shown below.
Elements are delimited with |, while Key/values are delimited with ^.
<?php
   $dom = new DOMDocument("1.0", 'utf-8');
   header ("Content-Type:text/xml");
   $QArray = explode('|',$_REQUEST[Q]); // separate elements
   foreach($QArray as $value) // create key/value pairs
   {
      $x = explode('^',$value);
      $XMLItems[$x[0]] = $x[1];
   }

   $root = $dom->createElement("RequestResult");
   $dom->appendChild($root);
   foreach($XMLItems as $key => $value)
   {
      $key = $dom->createElement($key);
      $root->appendChild($key);
      $variable = $dom->createTextNode($value);
      $key->appendChild($variable);
   }
   echo $dom->saveXML();
?>

Open in new window

0
Which technologies are  required  for SAML implementation.
And Saml  is to be  implemented  with  those technologies.
I  need  detail  information  on this as I am assigned that  task.
On net I   am  able to  find lot of articles  explaining how saml
works but I  did not find anything  practically  how it is implemented.
Instead  of  Service provider  we are  going to use  our own server.
0
hi,

I am not able to see xsl:when option while writing a xsl in the eclipse ide

not sure why? i am seeing other options though.
 how to get it xsl:when option as well ?

<td>
                                    <xslxsl:choose>
                                    <xsl:when
xslWhenMissing.png
0
I am working with a very large, very complicated schema.  I currently use this schema in JAVA to create XML files based on Job Information.  I am now being asked to also capture the data from each XML file and save to a CSV file, appending records for each job processed. Data from each job varies, so I need to make sure that the CSV file contains all nodes from the schema. I need advice on how to accomplish this.  

Thanks,
0
Hi all,

I get the error in the below code in .NET schema validation. The schema file is shared by some one else using J2EE.  My client is .NET.

"Attribute name="nonEmptyString"  not allowed" => in xs:simpletype


<xs:element name="ID" minOccurs="1" nillable="false">
        <xs:simpleType   name="nonEmptyString">
          <xs:restriction base="xs:string">
            <xs:pattern value="(\s*[^\s]\s*)+"/>
            <xs:maxLength value="15"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>

Open in new window

0
Hi, I' need to select a specific node in an xml doc... i have this which gives me everything

For Each xmlNode In objXML.documentElement.selectNodes("Data")

but i need a single node and its related nodes that has a specific value.. please see the xml

for example: I need to select only the Data where Bookcode = NEA-CSOP

Thank you

<DocumentElement>
<Data>
  <BookCode>NEA-CSOP</BookCode>
  <BPSday>3</BPSday>
  <BPSwk>6</BPSwk>
  <BPSmth>8</BPSmth>
  <Trackday>-44.6</Trackday>
  <TrackPnL>0</TrackPnL>
  <WAIVImv>0.239</WAIVImv>
  <WAIVexp>0.252</WAIVexp>
  <x90Day>0.256</x90Day>
</Data>

<Data>
<BookCode>NEA-EA1</BookCode>
<BPSday>18</BPSday>
<BPSwk>39</BPSwk>
<BPSmth>44</BPSmth>
<Trackday>-23.5</Trackday>
<TrackPnL>0</TrackPnL>
<WAIVImv>0.219</WAIVImv>
<WAIVexp>0.217</WAIVexp>
<x90Day>0.256</x90Day>
</Data>

<Data>
<BookCode>NEK-MV4</BookCode>
<BPSday></BPSday>
<BPSwk></BPSwk>
<BPSmth></BPSmth>
<Trackday></Trackday>
<TrackPnL></TrackPnL>
<WAIVImv></WAIVImv>
<WAIVexp></WAIVexp>
<x90Day></x90Day>
</Data>
<DocumentElement>

Open in new window

0
Free Tool: Port Scanner
LVL 11
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Exec Igen_SP_DedupeSearch '<ROOT><Dedupe PerMobile  = '+ @m_PerMobile +' /><Dedupe PerAMobile  = '+ @m_PerAMobile +' /><Dedupe CorrMobile  = '+ @m_CorrMobile +' />
                    <Dedupe CorrAMobile  = '+ @m_CorrAMobile +' /></ROOT>','Custinfo'


how can i pass value @m_permobile values in xml.
0
Below codes are working fine except
 
htmlOption += "<option>" + AmountMax + "</option>";

it only return 1 record/row when bondName='DMV Traffsdfasdfads', how can I loop the <Amount></Amount> and get them into the dropdown in HTML?


<Surety>
  <SuretyLine>
    <Commercial>
	<Bond>
        <GeneralInformation UI="BondInfo">
          <Name ID="bondName" PrefillValue="Yes">DMV Traffic Violators School Classroom</Name>
          <State ID="bondState" PrefillValue="Yes">CA</State>          
         </GeneralInformation>
        <Coverage Type="List">
          <Amount  PrefillValue="No" Min="10000" Max="10000" Year="1">10000</Amount>
         </Coverage>              
      </Bond>
      <Bond>
        <GeneralInformation UI="BondInfo">
          <Name ID="bondName" PrefillValue="Yes">DMV Traffsdfasdfads</Name>
          <State ID="bondState" PrefillValue="Yes">CA</State>          
         </GeneralInformation>
        <Coverage Type="List">
          <Amount  PrefillValue="No" Min="10000" Max="20000" Year="1"></Amount>
	  <Amount  PrefillValue="No" Min="20000" Max="30000" Year="1"></Amount>
         </Coverage>              
      </Bond>
</Commercial>
  </SuretyLine>
</Surety>

function fnGetBondAmount() {
    $.ajax({
        url: "http://localhost:5489/BondList.xml",
        success: function (xml) {
            parseSelectXMLBondAmountList(xml, "bondAmount", localStorage.getItem('bondState'), localStorage.getItem('bondName'))
        },
        error: 

Open in new window

0
I would like to make the dropdown sorted but not sure how to do it right. For those of you already helped me in the past. Please understand I ran with some trouble with your solutions and always get different results.

I want to re-post and hope to get working sample. Thanks


<select></select>

function fnGetBondNameList(bondState) {
            $.ajax({
                url: "http://localhost:5489/BondList.xml",
                success: function (xml) {
                    parseSelectXML(xml,"bondName","Bond",bondState);
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert("Status: " + xhr.status);
                    alert("Error: " + thrownError);
                }
            });
    } 

function parseSelectXML(xml, selectid, xmlnode, bondState) {
    var selecthtml = "", selectBondName = "";
    var options = [];
    $(xml).find(xmlnode).each(function () {
        if (bondState == $(this).find('GeneralInformation').find('State').text()) {
            selectBondName = $(this).find('GeneralInformation').find('Name').text();
        }
    });
    $("#" + selectid).prop("disabled", false);
    $('#' + selectid).html(selecthtml);
    $('#' + selectid + ' option:first').attr('selected', 'selected');
}

<?xml version="1.0" encoding="utf-8"?>
<Container>
  <GeneralInformation UI="BondInfo">
    <State>CA</State>
    <Name>Zebra</Name>
  </GeneralInformation>
  <GeneralInformation UI="BondInfo">
    

Open in new window

0
I'm experimenting with saving custom XML data to [shape] objects in PowerPoint using the object's CustomerData collection object which stores one or more CustomXML parts. There are three main methods and one property for the CustomerData object:

.Add (method)
.Item (method)
.Delete (method)
.Count (property)

Unlike other collections in the OM, items in the collection are read using a GUID string rather than a numerical index. for example:

Sub TestReadXML()
  Dim GUID As String
  GUID = "{CBAC284D-9000-4CFE-8E8F-FAD5CC8BCAA7}"
  With ActiveWindow.Selection.ShapeRange(1).CustomerData
    With .Item(GUID)
      Debug.Print .XML
    End With
  End With
End Sub

Open in new window


The GUID is created automatically by the .Add method when the CusomXMLPart is initially created so at that point it can be read and saved:

Sub TestWriteXML()
  Dim GUID As String
  With ActiveWindow.Selection.ShapeRange(1).CustomerData
    With .Add
      GUID = .Id
      .LoadXML "<testXML/>"
    End With
  End With
End Sub

Open in new window


Now, given the fact that the GUID cannot be present in more than one CustomXMLPart, either for the same object or multiple objects, when an object that contains a CustomXMLPart is copied, the original maintains its GUID but the copy is assigned a new one automatically.

Let's say I have a shape selected in the example above and I add the XML part, then copy/paste the shape, the new shape has been assigned the same XML data but with a different GUID.

How can I find out what that new GUID is?!

Is it deliberately inaccessible for security reasons or is this just an incomplete part of the PowerPoint OM?
0
How to generate C# classes from an XSD file?
0
Hi
I'm trying to extract elements from an XML file generated by mediainfo
I've done this before here but the format of the xml has changed

So how do I get at the file path on 'media ref' line and the other components
I'm getting "Not an ARRAY reference at"  line after dump
foreach my $file (@{$xml->{media}}) {

I tried to quote 'media ref' but didn't work

use strict;
use warnings;
use XML::Simple;
use Data::Dump qw(dump);

my $xml = XMLin('Path\\To\\Example.xml');

dump($xml);
foreach my $file (@{$xml->{media}}) {
    my ($FilePath,$NewName,$album,$movie);
    foreach my $key (qw(Complete_name CompleteName Collection Track Track_name Movie Movie_name Album Performer)) {
    print "key = $key\n";
        if (exists($file->{track}[0]{$key})){
            if(($key eq 'Complete_name') or ($key eq 'CompleteName')) {
                print 'File path = ', $file->{track}[0]{$key}, "\n";
                $FilePath = $file->{track}[0]{$key};
                }
            elsif(($key eq 'Collection') or ($key eq 'Album')){
                print 'Album = [', $file->{track}[0]{$key}, "]\n";
                $album = $file->{track}[0]{$key};
                }
            elsif($key =~ m/Track|Movie/i){
                print 'Movie = ', $file->{track}[0]{$key}, "\n";
                $movie = $file->{track}[0]{$key};
                }
            }
    }
  }  

Open in new window



Example.xml


Open in new window

0
I have jquery, xml call, and try to return some value while reading it. Please read the comment below and you will know my questions.

function fnGetBondAmount() {
    $.ajax({
        url: "http://localhost:5489/BondList.xml",
        success: function (xml) {
            parseSelectXMLBondAmountList(xml, "bondAmount", "CA", "DMV Traffic Violators School Classroom")
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert("Status: " + xhr.status);
            alert("Error: " + thrownError);
        }
    });
} 
function parseSelectXMLBondAmountList(xml, selectid, bondState, bondName) {
    var html = "";
    $('#' + selectid).prop("disabled", false);
    $(xml).find('GeneralInformation').each(function (i,e) {
        {
            if(bondState==$(this).find('State').text())
            {
                var selectedBondName = $(this).find('Name').text();
                if (selectedBondName == bondName) {
                    var selectedBondName = $(this).find('Name').text();
		    // code begin
			return me Coverage Type value (in this case it will be List)
			return me Amount 'Min' and 'Max' value (in this case it will be 10000, 10000)
		   // code end
                 }
             }            
        }
    });
    alert(html);
}


<Surety>
  <SuretyLine>
    <Commercial>
	<Bond>
        <GeneralInformation UI="BondInfo">
          <Name ID="bondName" PrefillValue="Yes">DMV Traffic Violators School Classroom</Name>
          <State

Open in new window

0
I have below jquery reading xml,
but not sure why below alert statement is not working.

Alert("HI " + bondState);


function fnGetBondAmount() {
    $.ajax({
        url: "http://localhost:5489/BondList.xml",
        success: function (xml) {
            parseSelectXMLBondAmountList(xml, "bondAmount", "CA", "Contractor")
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert("Status: " + xhr.status);
            alert("Error: " + thrownError);
        }
    });
}
function parseSelectXMLBondAmountList(xml, selectid,bondState,bondName) {
    var selecthtml = '', selectBondName, selectedbondAmountType;
    $('#' + selectid).prop("disabled", false);
    $(xml).find(xmlnode).each(function () {

        if (bondState == $(this).find('GeneralInformation').find('State').text()) {
            alert("HI " + bondState);             
      }
    });
}

<?xml version="1.0" encoding="utf-8"?>
<Surety>
  <SuretyLine>
    <Commercial>
      <Bond>
        <GeneralInformation UI="BondInfo">
		<State ID="bondState" PrefillValue="Yes">CA</State>
		<Product>A</Product>
	</GeneralInformation>
        <GeneralInformation UI="BondInfo">
		<State ID="bondState" PrefillValue="Yes">CA</State>
		<Product>B</Product>
	</GeneralInformation>
	<GeneralInformation UI="BondInfo">
		<State ID="bondState" PrefillValue="Yes">TX</State>
		<Product>C</Product>
	</GeneralInformation>
      </Bond>
    </Commercial>
  </SuretyLine>
</Surety>

Open in new window

0
Hello,

I'm creating a fairly long XML string with VBA and it's inserting random line breaks, which are breaking the XML if they end up in the middle of a tag.  One reason the strings are so long is that I'm converting a PDF to Base64 as part of it.  I've tried using a replace function to remove the Chr$(13) and Chr$(10) characters, but that doesn't seem to be doing it.

Here's a shorter example, but with the same problem at the end:

<?xml version="1.0"?><OutboundRequest><AccessControl><UserName>#####</UserName><Password>####</Password></AccessControl><Transmission><TransmissionControl><TransmissionID>TMH</TransmissionID><Resolution>STANDARD</Resolution><Priority>NORMAL</Priority><SelfBusy>ENABLE</SelfBusy><FaxHeader>@DATE1   @TIME3   ANYWHERE (555) 124-1215   Page%P of @TPAGES</FaxHeader></TransmissionControl><DispositionControl><DispositionURL></DispositionURL><DispositionLevel>BOTH</DispositionLevel><DispositionMethod>EMAIL</DispositionMethod><DispositionEmails><DispositionEmail><DispositionRecipient>JANE DOE</DispositionRecipient><DispositionAddress>JANEDOE@GOOGLE.COM</DispositionAddress></DispositionEmail></DispositionEmails></DispositionControl><Recipients><Recipient><RecipientName>JANE DOE</RecipientName><RecipientCompany></RecipientCompany><RecipientFax>0000000000</RecipientFax></Recipient></Recipients><Files><File><FileContents></FileContents><FileType>pdf</FileType></File></Files></Transmission></OutboundReq
uest>

The last tag is broken and that causes …
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hi,
  how to write stored procedure to pass xml as input parameter in sql server 2012 explain with simple example .
0
How to add a new plan if state name = 'NJ' and type name = 'Term Life'? and carrier name = 'Mutual of Omaha' using c#?


plan name="test"
plan id = "123"
plan healthtier="test"

<Products>
	<State Name="NJ">
		<Type Name="Subsidized">
			<Carrier Name="Chip" ID="100000008">
				<Plan Name="Chip" ID="100000322" HealthTier="" />
			</Carrier>
		</Type>
		<Type Name="Term Life">
			<Carrier Name="Mutual of Omaha" ID="100000017">
				<Plan Name="Term Life Express" ID="100000259" HealthTier="" />
		 	</Carrier>
		</Type>
		
	</State>
<State Name="PA"> 
		<Type Name="In Market">
			<Carrier Name="2017 Capital Blue Cross" ID="100000134">
				<Plan Name="Silver PPO 4500/0/10" ID="100002633" HealthTier="Silver" />
		 	</Carrier>
			<Carrier Name="2017 Geisinger Health Plan" ID="100000135">
		 	</Carrier>
		 			
		</Type>
		<Type Name="Out Market">
			<Carrier Name="2017 Capital Blue Cross" ID="100000134">
				<Plan Name="Gold PPO 1000/0/20" ID="100002634" HealthTier="Gold" />
			</Carrier>
			<Carrier Name="2018 Capital Blue Cross" ID="948120063">
				<Plan Name="Gold PPO 1000/0/20" ID="100002634" HealthTier="Gold" />
			</Carrier>  
		</Type> 
		<Type Name="Term Life">
			<Carrier Name="Assurity" ID="100000005">
				<Plan Name="Non-Med Term 350" ID="100000230" HealthTier="" />
			</Carrier> 
		</Type> 
	</State>
</Products>

Open in new window

0
I have this simple jquery codes to read xml.
and when the first OnChange I try is working, but when I try to select another state like "FL", it is not working.
Basically, when I select "FL", Contractor 2 should be showed,
when I select "CA", Contractor 1 should be showed.
Can you help me?

 
<Surety>
  <SuretyLine>
    <Commercial>
      <Bond>
        <GeneralInformation UI="BondInfo">
          <Name ID="bondName" PrefillValue="Yes">Contractor 1</Name>
          <State ID="bondState" PrefillValue="Yes">CA</State>
 	</GeneralInformation>
         <Image></Image>
        <Status>Online</Status>
      </Bond>
            <Bond>
        <GeneralInformation UI="BondInfo">
          <Name ID="bondName" PrefillValue="Yes">Contractor 2</Name>
          <State ID="bondState" PrefillValue="Yes">FL</State>
 	</GeneralInformation>
         <Image></Image>
        <Status>Online</Status>
      </Bond>
</Commercial>
</SuretyLine>
</Surety>

<script>
    function fnGetBondNameList(bondState) {
        $.ajax({
            url: "http://localhost:5489/BondList.xml",
            success: function (xml) {
                parseSelectXML(xml,"bondName","Bond",bondState)
            },
            error: function (xhr, ajaxOptions, thrownError) {
                alert("Status: " + xhr.status);
                alert("Error: " + thrownError);
            }
        });
    }
function parseSelectXML(xml, selectid, xmlnode,bondState) {
    var selecthtml = '';
    

Open in new window

0
I have xml below.

How to add a new plan if state name = 'NJ' and type name = 'Term Life'? using c#?
plan name="test"
plan id = "123"
plan healthtier="test"


<Products>
	<State Name="NJ">
		<Type Name="Subsidized">
			<Carrier Name="Chip" ID="100000008">
				<Plan Name="Chip" ID="100000322" HealthTier="" />
			</Carrier>
		</Type>
		<Type Name="Term Life">
			<Carrier Name="Mutual of Omaha" ID="100000017">
				<Plan Name="Term Life Express" ID="100000259" HealthTier="" />
		 	</Carrier>
		</Type>
		
	</State>
<State Name="PA"> 
		<Type Name="In Market">
			<Carrier Name="2017 Capital Blue Cross" ID="100000134">
				<Plan Name="Silver PPO 4500/0/10" ID="100002633" HealthTier="Silver" />
		 	</Carrier>
			<Carrier Name="2017 Geisinger Health Plan" ID="100000135">
		 	</Carrier>
		 			
		</Type>
		<Type Name="Out Market">
			<Carrier Name="2017 Capital Blue Cross" ID="100000134">
				<Plan Name="Gold PPO 1000/0/20" ID="100002634" HealthTier="Gold" />
			</Carrier>
			<Carrier Name="2018 Capital Blue Cross" ID="948120063">
				<Plan Name="Gold PPO 1000/0/20" ID="100002634" HealthTier="Gold" />
			</Carrier>  
		</Type> 
		<Type Name="Term Life">
			<Carrier Name="Assurity" ID="100000005">
				<Plan Name="Non-Med Term 350" ID="100000230" HealthTier="" />
			</Carrier> 
		</Type> 
	</State>
</Products>

Open in new window

0
Hello everyone,
I am trying to create XML record counts in the XML data file header.
Below code creates a XML data file "FinalXMLDataFile" from a SAS dataset "NewData" and the code works fine except counts are not working at all. Current record counts "previousCount" creates "0" counts in the XML Header in the counts section.  

Please let me know where the issue with record counts might be?

libname   mydir '/mydirectory'; 
filename outxml  '/mydirectory/FinalXMLDataFile.xml';

/* Macro variables to provide appropriate tab spacing */
%let tab="   ";
%let tab2="      ";
%let tab3="         ";
%let tab4="            ";
%let previousCount = 0; 


/*XML file information and headers*/
data _null_;
    file outxml;

if _N_ = 1 then
    do;
    
    put '<?xml version="1.0" encoding="UTF-8"?>';
    put '<XMLFile >';	
    put &tab. '<Header>';  
    put &tab2. "<CaseCount>%trim(&previousCount)</CaseCount>";     /* get record count of all XML records */ 
    put &tab2. '<Year>2017</Year>';
    put &tab. '</Header>';
    put &tab. '<Payload>';
    end;
run;

/* Using SAS dataset to create similar XML data file */
data _null_;
    file outxml mod;
    set mydir.NewData NOBS=lst;

    record = _N_ + &previousCount;
    
    if _n_=1 then do;
        put &tab2. '<MasterFile>'; 
    end;

    /*All Data records */
    put &tab3. '<AllData>'; 
    put &tab4. '<unit:VAR1>' VAR1+(-1)'</unit:VAR1>';
    put &tab4. '<unit:VAR2>' 

Open in new window

0
I have a very simple XML file. In a VBA Project for Word, I would like to read from this XML file named VerySimple and create a collection of Book Objects based on a Book class in my project.
I would appreciate help with VBA code that would help me achieve that.
The xmle file looks like this:
<?xml version="1.0"?>
<catalog>
   <book id="1">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
   </book>
   <book id="2">
      <author>Ralls, Kim</author>
      <title>Midnight Rain</title>
   </book>  
</catalog>

Open in new window

0

XML

20K

Solutions

13K

Contributors

Extensible Markup Language (XML) refers to the encoding of documents such that they can be read by both machines and humans. XML documents use tags to show the beginning and end of a set of data. XML is used extensively on websites to show volumes of data, and is the default for a number of office productivity suites. This topic includes discussions of XML-related technologies, such as XQuery (the XML Query language), XPath (the XML Path language), XSLT (eXtensible Stylesheet Language Transformations), XLink (the XML Linking language) and XPointer (the XML Pointer language).