[ 2 posts ]

gfk

  • Joined: Mon Aug 15, 2011 1:44 pm
  • Posts: 2
  • Offline
  • Profile

DataSchema for SimpleDB output?

Post Posted: Mon Aug 15, 2011 1:53 pm
+0-
Hi,

I'm trying to parse data coming from SimpleDB but I'm having trouble making a DataSchema that will work with their XML output:
Code:
            <SelectResult>
                <Item>
                    <Name>1</Name>
                    <Attribute>
                        <Name>author</Name>
                        <Value>gfk</Value>
                    </Attribute>
                    <Attribute>
                        <Name>title</Name>
                        <Value>First thing to do</Value>
                    </Attribute>
                </Item>
                <Item>
                    <Name>2</Name>
                    <Attribute>
                        <Name>author</Name>
                        <Value>gfk</Value>
                    </Attribute>
                    <Attribute>
                        <Name>title</Name>
                        <Value>nother thing to do</Value>
                    </Attribute>
                </Item>
            </SelectResult>


My best guess is below, but it doesn't seem to work:

Code:
{
        resultListLocator: "Item",
        resultFields: [
            {key:"id", locator:"Name"},
            {key:"Attribute/Name", locator:"Attribute/Value"}
        ]
    }


If it's not already clear, I'd like to have the data like this:

Code:
[ {id:"1", author:"gfk", title:"First thing to do"}, {id:"2", author:"gfk", title:"nother thing to do"} ]


Thanks a lot,
GFK's

Todd Smith

YUI Contributor

  • Username: stlsmiths
  • Joined: Thu Nov 05, 2009 10:03 am
  • Posts: 675
  • GitHub: stlsmiths
  • Gists: stlsmiths
  • IRC: t_smith
  • Offline
  • Profile

Re: DataSchema for SimpleDB output?

Post Posted: Mon Aug 15, 2011 3:14 pm
+0-
Have you reviewed http://developer.yahoo.com/yui/3/dataschema/#xml?

The multiple ATTRIBUTE nodes may be a little tricky, but I would recommend something like
Code:
{
    resultListLocator: "Item",
    resultFields: [
        { key:"id", locator:"Name" },
        { key:"author", locator:"Attribute[1]/Value" },
        { key:"title", locator:"Attribute[2]/Value" }
    ]
}

You might be able to look into some advanced XPath selectors such as "Attribute/[Name='author']/Value" or such, but the above should work.
Todd
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum